wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basic 1

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

How do you insert COMMENTS in Python code?

a)

//This is a comment

b)

/*This is a comment*/

c)

#This is a comment

2.

Which one is NOT a legal variable name?

a)

Myvar

b)

_myvar

c)

my-var

d)

my_var

3.

How do you create a variable with the numeric value 5?

a)

x=5

b)

x=int(5)

c)

Both the other answer are correct

4.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

5.

How do you create a variable with the floating number 2.8?

a)

x=2.8

b)

x=float(2.8)

c)

Both the other answer are correct

6.

In Python, 'Hello', is the same as "Hello"

a)

False

b)

True

7.

Which operator is used to multiply numbers?

a)

x

b)

*

c)

%

d)

#

8.

What is the name of the programming language we are learning?

a)

Scratch

b)

Java

c)

Python

d)

Javascript

9.

What will be the output?

name = "Dave"

print (name)

a)

name

b)

Dave

c)

'Dave'

d)

(name)

10.

When you have an error in your code what is the term to summarise finding and fixing that error?

a)

Error checking

b)

Syntax finder

c)

Debugging

d)

Error finder

11.

What Python command lets the user enter an answer to a question?

a)

write()

b)

insert()

c)

print()

d)

input()

12.

Which statement correctly assigns the string "Tanner" to the variable name?

a)

name = print( "Tanner")

b)

name = "Tanner"

c)

input("Tanner")

d)

name = input("Tanner")

13.

The character that must be at the end of the line for in range()

a)

;

b)

:

c)

,

d)

""

14.

Numbers with a decimal point belong to a type called...

a)

pointing

b)

integers

c)

float

d)

decimal

15.

>>> print(r'foo\\bar\nbaz')

Which of the following is the correct REPL output?

a)

foo\\bar\nbaz

b)

foo\\barnbaz

c)

foo bar nbaz

d)

'foo\\bar\nbaz'

16.

x = 5

y = 6

print(x*y)

a)

11

b)

x*y

c)

30

d)

56

17.

age = input("Enter Age (as integer): ")

newAge = age + 20

print ("your age in 20 years is:", newAge)

you enter

15

a)

value of age is 15

value of newAge is 35

output is: your age in 20 years is: 35

b)

value of age is 15

value of newAge is "age + 20"

output is: your age in 20 years is: 35

c)

value of age is 15

value of newAge is 20

output is: your age in 20 years is: 20

d)

value of age is 15

value of newAge is 15+20

output is: your age in 20 years is: 35

18.

A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.

a)

False

b)

True

19.

what is the code for a STRING in python?

a)

str

b)

stri

c)

stg

d)

string

20.

What is a correct syntax to output "Hello World" in Python?

a)

print( "Hello World")

b)

echo( "Hello World");

c)

display( "Hello World")

d)

echo "Hello World"