0
0
Azurecloud~10 mins

Scripting with variables and loops in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable named 'resourceGroup' with the value 'myResourceGroup'.

Azure
resourceGroup = "[1]"
Drag options to blanks, or click blank then click option'
AmyGroup
BresourceGroup
CgroupName
DmyResourceGroup
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the string value.
Using the wrong variable name.
2fill in blank
medium

Complete the code to create a loop that iterates over the list of VM names.

Azure
for vm in [1]:
    print(vm)
Drag options to blanks, or click blank then click option'
A["vm1", "vm2", "vm3"]
BvmList
CvmNames
Dvms
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not defined.
Not using a list to iterate over.
3fill in blank
hard

Fix the error in the code to correctly increment the counter variable inside the loop.

Azure
count = 0
for i in range(5):
    count [1] 1
Drag options to blanks, or click blank then click option'
A+=
B-=
C==
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment = instead of increment +=.
Using comparison operator == by mistake.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps VM names to their lengths, but only for names longer than 3 characters.

Azure
{vm[1]: len(vm) for vm in vmList if len(vm) [2] 3}
Drag options to blanks, or click blank then click option'
A.upper()
B>
C<
D.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator.
Not applying a string method to the VM name.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps VM names in lowercase to their status, but only include VMs with status 'running'.

Azure
{vm[1]: status for vm, status in vmStatus.items() if status [2] '[3]'}
Drag options to blanks, or click blank then click option'
A.lower()
B==
Crunning
D.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong string method for VM names.
Using assignment = instead of comparison ==.
Misspelling the status string.