ITS Python Practice Exam 1 - Python
|\ |\ |\ |\ |\ |\ |\
Programming questions with answers |\ |\ |\
Python makes the distinction between integers and
|\ |\ |\ |\ |\ |\ |\
floating variables. - CORRECT ANSWERS ✔✔Yes |\ |\ |\ |\ |\
When declaring variables in Python, a data type must be
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
specified. - CORRECT ANSWERS ✔✔No |\ |\ |\ |\
When setting a boolean variable, the value must start
|\ |\ |\ |\ |\ |\ |\ |\ |\
with a capital letter. - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\ |\
A developer wants to make sure a serial number cannot
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
be used in a calculation and that a dollar amount entered
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
as a whole number can have decimals. Then, a message
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
should be displayed to tell a customer the serial number
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
and price for the products. Using the drop-down arrows,
|\ |\ |\ |\ |\ |\ |\ |\ |\
fill in the code to use the proper functions to convert the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
data to the necessary data types. - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔str
float
,
,A developer needs to write code to reverse the character
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
output of a product code. Which variable declaration will
|\ |\ |\ |\ |\ |\ |\ |\ |\
reverse one of the product codes? - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔[::-1]
In this scenario, the number of complete units needs to
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
be displayed, meaning that anything after a decimal point
|\ |\ |\ |\ |\ |\ |\ |\
needs to not be represented. To accomplish this, the int
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
function is needed as it extracts the whole number from a
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
value with a floating decimal. The round function will not
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
work because it will round the number up to 20. The floor
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
function rounds a number down to the nearest integer.
|\ |\ |\ |\ |\ |\ |\ |\ |\
The ceil function will raise the number to 20. The correct
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
code is as follows: - CORRECT ANSWERS ✔✔int
|\ |\ |\ |\ |\ |\ |\
A developer needs to build a data structure with animals
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
and then sort the structure. Using drag and drop, drag the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
following lines of code into the correct order to produce
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
this output: |\
Bears
Jaguars
Lions
Panthers - CORRECT ANSWERS |\ |\ |\ |\
✔✔animals=["Bears","Panthers","Lions"]
animals.append("Jaguars")
animals.sort()
, for animal in animals:
|\ |\ |\
print(animal)
x=5
y=3
z=x+y> and x*y<15 or x-y>2 - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\
✔✔z=
pieces=["king", "queen", "rook", "bishop", "knight, |\ |\ |\ |\
"pawn"]
|\
pieces.sort() - CORRECT ANSWERS ✔✔print(pieces[5])
|\ |\ |\ |\
print(pieces[-1])
a == 90 - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\
b == 2.5 - CORRECT ANSWERS ✔✔No
|\ |\ |\ |\ |\ |\
c == -9 - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\
if grade __ 100: print ("Outstanding")
|\ |\ |\ |\ |\
elif grade __ 90: print ("Great")
|\ |\ |\ |\ |\
elif grade __ 70: print("Study hard")
|\ |\ |\ |\ |\
|\ |\ |\ |\ |\ |\ |\
Programming questions with answers |\ |\ |\
Python makes the distinction between integers and
|\ |\ |\ |\ |\ |\ |\
floating variables. - CORRECT ANSWERS ✔✔Yes |\ |\ |\ |\ |\
When declaring variables in Python, a data type must be
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
specified. - CORRECT ANSWERS ✔✔No |\ |\ |\ |\
When setting a boolean variable, the value must start
|\ |\ |\ |\ |\ |\ |\ |\ |\
with a capital letter. - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\ |\
A developer wants to make sure a serial number cannot
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
be used in a calculation and that a dollar amount entered
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
as a whole number can have decimals. Then, a message
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
should be displayed to tell a customer the serial number
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
and price for the products. Using the drop-down arrows,
|\ |\ |\ |\ |\ |\ |\ |\ |\
fill in the code to use the proper functions to convert the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
data to the necessary data types. - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔str
float
,
,A developer needs to write code to reverse the character
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
output of a product code. Which variable declaration will
|\ |\ |\ |\ |\ |\ |\ |\ |\
reverse one of the product codes? - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔[::-1]
In this scenario, the number of complete units needs to
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
be displayed, meaning that anything after a decimal point
|\ |\ |\ |\ |\ |\ |\ |\
needs to not be represented. To accomplish this, the int
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
function is needed as it extracts the whole number from a
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
value with a floating decimal. The round function will not
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
work because it will round the number up to 20. The floor
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
function rounds a number down to the nearest integer.
|\ |\ |\ |\ |\ |\ |\ |\ |\
The ceil function will raise the number to 20. The correct
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
code is as follows: - CORRECT ANSWERS ✔✔int
|\ |\ |\ |\ |\ |\ |\
A developer needs to build a data structure with animals
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
and then sort the structure. Using drag and drop, drag the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
following lines of code into the correct order to produce
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
this output: |\
Bears
Jaguars
Lions
Panthers - CORRECT ANSWERS |\ |\ |\ |\
✔✔animals=["Bears","Panthers","Lions"]
animals.append("Jaguars")
animals.sort()
, for animal in animals:
|\ |\ |\
print(animal)
x=5
y=3
z=x+y> and x*y<15 or x-y>2 - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\
✔✔z=
pieces=["king", "queen", "rook", "bishop", "knight, |\ |\ |\ |\
"pawn"]
|\
pieces.sort() - CORRECT ANSWERS ✔✔print(pieces[5])
|\ |\ |\ |\
print(pieces[-1])
a == 90 - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\
b == 2.5 - CORRECT ANSWERS ✔✔No
|\ |\ |\ |\ |\ |\
c == -9 - CORRECT ANSWERS ✔✔Yes
|\ |\ |\ |\ |\ |\
if grade __ 100: print ("Outstanding")
|\ |\ |\ |\ |\
elif grade __ 90: print ("Great")
|\ |\ |\ |\ |\
elif grade __ 70: print("Study hard")
|\ |\ |\ |\ |\