Font size
WorksheetsPython Test 1
Total questions: 87
Worksheet time: 59mins
name = 'Dave'
print (name)
Which is the Python logo?
What is a input?
A function that allows us to ask the user to enter some data.
To plug in something.
Data displayed on a screen.
A function
What function is used to output a message in python?
print("")
input=name
name=input
x = 5
y = 6
print(x*y)
The code above displays the following:
11
x*y
Syntax Error
30
Operators used in python:
divide, multiply, add, subtract
/, *, +, -
div, mul, +, -
\, x, +, -
~, *, +, -
Which of the following is a command to have a message appear on the screen?
write
msg
input
Pick the Python command used to let the user type in some data
get
input
int
float
Which of the following is a Python command word used to indicate we want to work with WHOLE numbers
input
int
float
Which of the following is a Python command word used to indicate we want to work with DECIMAL numbers
input
int
float
Which of the following is a Python command word used to indicate we want to set up a fixed loop
while
next
for
What would be printed by the command
print('12-5')
12-5
'12-5'
7
'7'
print(Hello world!)
Which of the following is used in Python to give a value to a variable
:=
==
=
What would be printed by the command
print('12-5')
12-5
'12-5'
7
'7'
Which of the operators do we use if we want at least one condition to be true?
and
or
else
not
print(Hello world!)
What will be the output of the following statement?
type('5')
str
int
float
Boolean
What is the correct file extension for Python files?
.py
.pt
.pyt
.pyth
How do you create a variable with the numeric value 5?
Both are correct
x=5
x=int(5)
Which operator can be used to compare two values?
=
<>
><
==
Which of the following is a data type in Python? Select multiple answers.
int
words
string
decimals
a = "Good Morning!"
print(len(a))
13
12
11
14
a = "Hello, World!"
print(a.lower())
hello, World!
HELLO, WORLD!
hello, world!
Error
x = 23
y = 3
print(x // y)
7
7.6666
7.7
Error
print(Hello world!)
print(3+4)
print("3+4")
What will the output be from the following code?
print("Hello world!\nHello world!") (aka new line)
Hello world! Hello world!
Hello world!
Hello world!
SyntaxError
Hello world!
print("Hello" + "world!")
print("Hello" + "world" + "today")
Everything that we want do display in a print() function must:
be inside parentheses - ()
quotation marks - ""
be inside single quotation marks - ''
be inside hash marks - #
In Python, variables are black, functions are purple and strings are green? True or False
True
False
What is a correct syntax to output "Hello World" in Python?
echo("Hello World")
echo "Hello World"
print("Hello World")
PRINT("Hello World")
What is the correct file extension for Python files?
.py
.pt
.pyt
.pyth
Which operator can be used to compare two values?
=
<>
><
==
How do you create a variable with the numeric value 5?
Both are correct
x=5
x=int(5)
How do you create a variable with the floating number 2.8?
x=2.8
x=float(2.8)
both are correct
If num1 = 5
num2 = 6
then what will be the output of num1*num2
11
6
30
-1
If num1 = 3
num2 = 4
then what will be the output of num1 ** num2
3
7
12
81
Which operator checks if a value is equal to another value?
+
-
==
!=
Which is the Python logo?
What is an input?
A command that allows us to ask the user to enter some data.
To plug in something.
Data displayed on a screen.
A function
What is an output?
A piece of data that is shown on the screen.
Data that the user enters
An output
A orange
To display the following on screen
Hello World!
the following command should be used:
print(Hello World!)
print("Hello World!")
print("Hello World" + !)
print"(Hello World!)"
x = 5
y = 6
print("x*y")
The code above displays the following:
11
x*y
Syntax Error
30
Choose the correct operators used in python:
divide, multiply, add, subtract
/, *, +, -
div, mul, +, -
\, x, +, -
~, *, +, -
Which operator checks if a value is not equal to another value?
==
+=
!=
=
A data type that can have one of two values: True or False
boolean
variable
modulo
interpreter
name = "Bob"
if name == "Bob":
print ("Hello " + name)
else:
print ("I dont know you")
name = "Bob"
if name == "Bob":
print ("Hello " + name)
else:
print ("I dont know you")
Integers are ____________ and floats are _____________
whole numbers and exponents
powers and fractions
fractions and whole numbers
whole numbers and decimal numbers
print(3+4)
print(3*4+5)
Which of these is a string?
42
True
"This one!"
No, this one
How to create a numeric variable age with a value of 10
age = 10
age = int(10)
age = "10"
In python, "Hello World" is the same as 'Hello World'
True
False
How is a block of code defined in Python ?
with indentation
with paranthesis
with curly braces
age = '5'
In the code above, age is a
string
integer
floating point
