NEW
Font size
WorksheetsPython Basic 1
Total questions: 20
Worksheet time: 10mins
How do you insert COMMENTS in Python code?
//This is a comment
/*This is a comment*/
#This is a comment
Which one is NOT a legal variable name?
Myvar
_myvar
my-var
my_var
How do you create a variable with the numeric value 5?
x=5
x=int(5)
Both the other answer are correct
What is the correct file extension for Python files?
.py
.pt
.pyt
.pyth
How do you create a variable with the floating number 2.8?
x=2.8
x=float(2.8)
Both the other answer are correct
In Python, 'Hello', is the same as "Hello"
False
True
Which operator is used to multiply numbers?
x
*
%
#
What is the name of the programming language we are learning?
Scratch
Java
Python
Javascript
What will be the output?
name = "Dave"
print (name)
name
Dave
'Dave'
(name)
When you have an error in your code what is the term to summarise finding and fixing that error?
Error checking
Syntax finder
Debugging
Error finder
What Python command lets the user enter an answer to a question?
write()
insert()
print()
input()
Which statement correctly assigns the string "Tanner" to the variable name?
name = print( "Tanner")
name = "Tanner"
input("Tanner")
name = input("Tanner")
The character that must be at the end of the line for in range()
;
:
,
""
Numbers with a decimal point belong to a type called...
pointing
integers
float
decimal
>>> print(r'foo\\bar\nbaz')
Which of the following is the correct REPL output?
foo\\bar\nbaz
foo\\barnbaz
foo bar nbaz
'foo\\bar\nbaz'
x = 5
y = 6
print(x*y)
11
x*y
30
56
age = input("Enter Age (as integer): ")
newAge = age + 20
print ("your age in 20 years is:", newAge)
you enter
15
value of age is 15
value of newAge is 35
output is: your age in 20 years is: 35
value of age is 15
value of newAge is "age + 20"
output is: your age in 20 years is: 35
value of age is 15
value of newAge is 20
output is: your age in 20 years is: 20
value of age is 15
value of newAge is 15+20
output is: your age in 20 years is: 35
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.
False
True
what is the code for a STRING in python?
str
stri
stg
string
What is a correct syntax to output "Hello World" in Python?
print( "Hello World")
echo( "Hello World");
display( "Hello World")
echo "Hello World"
