WGU PYTHON D522 UPDATED ACTUAL QUESTIONS
WITH CORRECT ANSWERS
Question 1.
Which Python datatypes allow arrays with duplicates?
ANSWER
list and tuple
Question 2.
print(~ 3)
ANSWER
bitwise operator NOT
inverts all the bits
3 (0000000000000011)
-4 (1111111111111100)
Question 3.
Which modifiers are used to show a value's positive or negative sign?
ANSWER
i. := shows negative sign in the left most position
ii. :+ shows sign for positive and negative numbers
iii. :- shows sign for negative number only
iv. :(space) shows sign for negative and an extra space for a positive number
Question 4.
print(6 ^ 3)
ANSWER
bitwise operator XOR
compare bits and set each bit to 1 if only one bit is 1
6 (0000000000000110)
3 (0000000000000011)
5 (0000000000000101)
,Question 5.
What is a sequence type?
ANSWER
a collection of objects ordered from left to right; the first object is 0; each object's position is its
index
Question 6.
How do you determine how many items are in a list?
ANSWER
print(len(yourlist))
Question 7.
What is a continue statement?
ANSWER
Causes a loop to immediately jump back to the while or for statement
Question 8.
Fastest way to isolate and remove the last digit of an integer
ANSWER
i. % 10
ii. // 10
Question 9.
What does != mean?
ANSWER
not equal to
,Question 10.
Can you generate random numbers in Python?
ANSWER
i. no random function, but there is a random module
ii. import random
iii. print(random.randrange(1,10))
Question 11.
print(a.replace("H", "J"))
ANSWER
replace a string with another string
Question 12.
What is the modifier to show the value in fix point number format?
ANSWER
i. if number not specified, shows 6 digits after decimal
ii. :f show inf and nan lowercase
iii. :F show inf and nan uppercase
Question 13.
What is the modifier to show the value in the corresponding Unicode character?
ANSWER
:c
Question 14.
What modifiers are used to set thousand separators?
ANSWER
i. :, comma
ii. :_ underscore
, Question 15.
What is an integer?
ANSWER
positive or negative whole number of unlimited length
Question 16.
What are the bitwise operators?
ANSWER
&
|
^
~
<<
>>
Question 17.
What is enumerate( )?
ANSWER
retrieves the index and value of an element in a list
Question 18.
a=(f"My name is John, I am {age}")
print(a)
ANSWER
f-string; { } is the placeholder/modifier
Question 19.
What is the modifier to show the value in decimal format?
ANSWER
:d
WITH CORRECT ANSWERS
Question 1.
Which Python datatypes allow arrays with duplicates?
ANSWER
list and tuple
Question 2.
print(~ 3)
ANSWER
bitwise operator NOT
inverts all the bits
3 (0000000000000011)
-4 (1111111111111100)
Question 3.
Which modifiers are used to show a value's positive or negative sign?
ANSWER
i. := shows negative sign in the left most position
ii. :+ shows sign for positive and negative numbers
iii. :- shows sign for negative number only
iv. :(space) shows sign for negative and an extra space for a positive number
Question 4.
print(6 ^ 3)
ANSWER
bitwise operator XOR
compare bits and set each bit to 1 if only one bit is 1
6 (0000000000000110)
3 (0000000000000011)
5 (0000000000000101)
,Question 5.
What is a sequence type?
ANSWER
a collection of objects ordered from left to right; the first object is 0; each object's position is its
index
Question 6.
How do you determine how many items are in a list?
ANSWER
print(len(yourlist))
Question 7.
What is a continue statement?
ANSWER
Causes a loop to immediately jump back to the while or for statement
Question 8.
Fastest way to isolate and remove the last digit of an integer
ANSWER
i. % 10
ii. // 10
Question 9.
What does != mean?
ANSWER
not equal to
,Question 10.
Can you generate random numbers in Python?
ANSWER
i. no random function, but there is a random module
ii. import random
iii. print(random.randrange(1,10))
Question 11.
print(a.replace("H", "J"))
ANSWER
replace a string with another string
Question 12.
What is the modifier to show the value in fix point number format?
ANSWER
i. if number not specified, shows 6 digits after decimal
ii. :f show inf and nan lowercase
iii. :F show inf and nan uppercase
Question 13.
What is the modifier to show the value in the corresponding Unicode character?
ANSWER
:c
Question 14.
What modifiers are used to set thousand separators?
ANSWER
i. :, comma
ii. :_ underscore
, Question 15.
What is an integer?
ANSWER
positive or negative whole number of unlimited length
Question 16.
What are the bitwise operators?
ANSWER
&
|
^
~
<<
>>
Question 17.
What is enumerate( )?
ANSWER
retrieves the index and value of an element in a list
Question 18.
a=(f"My name is John, I am {age}")
print(a)
ANSWER
f-string; { } is the placeholder/modifier
Question 19.
What is the modifier to show the value in decimal format?
ANSWER
:d