WGU PYTHON D522 UPDATED ACTUAL QUESTIONS
WITH CORRECT ANSWERS
Question 1.
What kind of variable would x = [ ] result in?
ANSWER
list
Question 2.
What is a Name Error?
ANSWER
program tries to use a variable that does not exist
Question 3.
What are the identity operators?
ANSWER
is, is not
Question 4.
print(bool("Hello")) print(bool("15")) print(bool(x))
ANSWER
Boolean examples of True
Question 5.
float( )
ANSWER
casts a float from an integer literal, a float literal, or a string literal
,Question 6.
What is a continue statement?
ANSWER
Causes a loop to immediately jump back to the while or for statement
Question 7.
How do you denote a modifier in an f-string placeholder?
ANSWER
in placeholder, after name of variable or value, use a : followed by formatting type e.g., txt =
f"The price is {95:.2f} dollars"
Question 8.
How do you denote a placeholder in an f-string?
ANSWER
{}
e.g., txt = f"The price is {price} dollars"
Question 9.
What is the modifier to show the value in decimal format?
ANSWER
:d
Question 10.
What are some characteristics of a tuple?
ANSWER
ordered; unchangeable; allows duplicate values
,Question 11.
How to print an * rectangle
ANSWER
num_rows = int(input())
num_cols = int(input())
for a in range(num_rows):
for b in range(num_cols):
print('*', end=' ')
print()
Question 12.
What is the modifier to show the value in hex format?
ANSWER
:x lowercase
:X uppercase
Question 13.
What is dynamic typing?
ANSWER
the interpreter determines the type of objects as the program executes; the programmer does
not have to define them
Question 14.
Which modifiers are used to show a value's positive or negative sign?
ANSWER
:= shows negative sign in the left most position
:+ shows sign for positive and negative numbers
:- shows sign for negative number only
:(space) shows sign for negative and an extra space for a positive number
Question 15.
print(a.replace("H", "J"))
ANSWER
replace a string with another string
, Question 16.
What modifiers are used to set thousand separators?
ANSWER
:, comma
:_ underscore
Question 17.
What built-in data type is used when you assign a set to your variable?
ANSWER
set
x = {"apple", "banana", "cherry"}
x = set(("apple", "banana", "cherry"))
frozenset
x = frozenset({"apple", "banana", "cherry"})
x = frozenset(("apple", "banana", "cherry"))
Question 18.
What does an interpreter do with objects?
ANSWER
creates and manipulates objects as needed to run code; assigns an object to a location
somewhere in memory
Question 19.
What is the modifier to show the value in scientific format?
ANSWER
:e
:E for uppercase E
Question 20.
How do you name a variable versus a constant?
ANSWER
variable_name CONSTANT_NAME
WITH CORRECT ANSWERS
Question 1.
What kind of variable would x = [ ] result in?
ANSWER
list
Question 2.
What is a Name Error?
ANSWER
program tries to use a variable that does not exist
Question 3.
What are the identity operators?
ANSWER
is, is not
Question 4.
print(bool("Hello")) print(bool("15")) print(bool(x))
ANSWER
Boolean examples of True
Question 5.
float( )
ANSWER
casts a float from an integer literal, a float literal, or a string literal
,Question 6.
What is a continue statement?
ANSWER
Causes a loop to immediately jump back to the while or for statement
Question 7.
How do you denote a modifier in an f-string placeholder?
ANSWER
in placeholder, after name of variable or value, use a : followed by formatting type e.g., txt =
f"The price is {95:.2f} dollars"
Question 8.
How do you denote a placeholder in an f-string?
ANSWER
{}
e.g., txt = f"The price is {price} dollars"
Question 9.
What is the modifier to show the value in decimal format?
ANSWER
:d
Question 10.
What are some characteristics of a tuple?
ANSWER
ordered; unchangeable; allows duplicate values
,Question 11.
How to print an * rectangle
ANSWER
num_rows = int(input())
num_cols = int(input())
for a in range(num_rows):
for b in range(num_cols):
print('*', end=' ')
print()
Question 12.
What is the modifier to show the value in hex format?
ANSWER
:x lowercase
:X uppercase
Question 13.
What is dynamic typing?
ANSWER
the interpreter determines the type of objects as the program executes; the programmer does
not have to define them
Question 14.
Which modifiers are used to show a value's positive or negative sign?
ANSWER
:= shows negative sign in the left most position
:+ shows sign for positive and negative numbers
:- shows sign for negative number only
:(space) shows sign for negative and an extra space for a positive number
Question 15.
print(a.replace("H", "J"))
ANSWER
replace a string with another string
, Question 16.
What modifiers are used to set thousand separators?
ANSWER
:, comma
:_ underscore
Question 17.
What built-in data type is used when you assign a set to your variable?
ANSWER
set
x = {"apple", "banana", "cherry"}
x = set(("apple", "banana", "cherry"))
frozenset
x = frozenset({"apple", "banana", "cherry"})
x = frozenset(("apple", "banana", "cherry"))
Question 18.
What does an interpreter do with objects?
ANSWER
creates and manipulates objects as needed to run code; assigns an object to a location
somewhere in memory
Question 19.
What is the modifier to show the value in scientific format?
ANSWER
:e
:E for uppercase E
Question 20.
How do you name a variable versus a constant?
ANSWER
variable_name CONSTANT_NAME