AUTOMATION WGU
D522 EXAMS
QUESTIONS WITH
CORRECT ANSWERS
, PYTHON FOR IT AUTOMATION WGU D522 EXAMS
QUESTIONS WITH CORRECT ANSWERS
Consider the following Python code:
colors = ['red', 'blue', 'green'] colors.insert(1, 'yellow')
What will be the value of colors after executing this code? - Answer-['red', 'yellow', 'blue', 'green']
when using the .insert(), it doesn't replace the value in that position, it inserts into that place.
How are items in a tuple accessed? - Answer-By placing the index of the item inside square
brackets [] after the tuple name
How can a global variable be created inside a function in Python? - Answer-By declaring the
variable with the 'global' keyword
How can multiple Python variables of different types be output using the print() function? -
Answer-By separating each variable with a comma
What are the 3 common naming conventions used in Python, and what is their format? -
Answer-Camel case: each word, except for the first word, starts with a capital letter
Pascal case: each word starts with a capital letter
Snake case: each word in the variable is separated by an underscore.
What are the 3 components of a string slice? - Answer-string [start:stop:step]
· Start: the index from which the slicing begins (inclusive)
· Stop: the index at which the slicing ends (exclusive)
· Step (optional): The step or stride between characters.