wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python basics by vaishali

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

To display something on the screen, use this command:

a)

print()

b)

Print()

c)

screen()

d)

write()

e)

display()

2.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

3.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
4.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
5.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
6.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
7.

Which operator performs a division?

a)

-

b)

+

c)

/

d)

*

8.

Which operator checks if a value is equal to another value?

a)

+

b)

=

c)

==

d)

!=

9.

Which operator checks if a value is not equal to another value?

a)

==

b)

+=

c)

!=

d)

=

10.
Converts a number to a string
a)
str()
b)
int()
c)
parseInt()
d)
convert
11.
a data type than can have one of two values: True or False
a)
boolean
b)
variable
c)
modulo
d)
interpreter
12.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
13.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
14.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
15.
Numbers with a decimal point belong to a type called...
a)
pointing
b)
integers
c)
decimal
d)
float
16.
When you have an error in your code what is the term to summarise finding and fixing that error?
a)
Error checking
b)
Debugging
c)
Syntax finder
d)
Error finder
17.

Which of the following is correct?

a)

Comments are for programmers for better understanding of the program.

b)

Python Interpreter ignores comment.

c)

You can write multi-line comments in Python using triple quotes, either ''' or """.

d)

All of the above

18.

In the following code, n is a/an _______?


n = '5'

a)

integer

b)

string

c)

tuple

d)

operator

19.

What is used to take input from the user in Python?

a)

cin

b)

scanf()

c)

input()

d)

<>

20.

What is a input?

a)

A built-in function that allows us to prompt the user to enter data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A device.

21.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

22.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)

Syntax Error

d)
Hello world!
23.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)

Syntax Error

24.

What does the following code do? myAge = int(myAge)

a)

Converts the variable myAge to a integer

b)

Syntax Error

c)

Converts the variable myAge from a integer to a string

d)

Missing input

25.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
26.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
27.

Are Double or single quotes used in Python?

a)

Double

b)

Single

c)

Neither

d)

Both work

28.

Python correct naming convention for variables is?

a)

new_user25

b)

NewUser25

c)

25_new_user

d)

25NewUser

e)

NEWUSER25

29.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

d)

4

30.
What will the output be from the following code?
print("Hello" + 2 + "world")
a)
Hello 2 world
b)
Hello2world
c)
TypeError
d)
HelloHelloworld
31.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
32.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
33.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

34.

What will be the output for following python programme:

x = 100

y = float(x)

print(y)

a)

200

b)

100.0

c)

100

d)

Can't convert an integer to a floating number.

35.

Which of the statements below is true about indentation in Python?

a)

Indentation only matters in for loops. Then, everything must be indented one level.

b)

Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read.

c)

Indentation always matters in Python. Every statement must be aligned correctly.

d)

Indentation only matters in functions. Then, everything must be indented one level.

36.
Which of the following is a multi-line comment?
a)
"""Multi-line Comment Here"""
b)
""Multi-line Comment Here""
c)
"Multi-line Comment Here"
d)
'Multi-line Comment Here'
37.
Which of the following statements would return the value 2?
a)
new_var = 8 % 3
b)
new_var = 4 % 2
c)
new_var = 10 ** 2
d)
new_var = "4 % 2"
38.
Which of the following text strings is correct?
a)
new_var = "Tim/'s Computer"
b)
new_var = "Tim\'s Computer"
c)
new_var = "Tim's Computer"
d)
new_var = Tim's Computer
39.

Which one is NOT a legal variable name?

a)

_fname

b)

first_Name

c)

f-Name

d)

Fname

40.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(type(x))

b)

print(typeof(x))

c)

print(type of (x))

d)

print(typeOf(x))

41.

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

a)

True

b)

False

c)

Cant say

d)

both are wrong

42.

What is the correct file extension for Python files?

a)

.pyth

b)

.py

c)

.pt

d)

.pyt

43.

Who developed the Python programming language?

a)

Rasmus Lerdorf

b)

Wick van Rossum

c)

Guido van Rossum

d)

Guido Van Stom

44.

Full form of IDLE in python is:

(a)  

45.
What is the meaning of the following comparison operator?
a > b
a)
Greater than
b)
Less than
c)
Not equal to
d)
Greater than or equal to
46.
What is the meaning of the following comparison operator?
a >= b
a)
Equal to
b)
Not equal to
c)
Greater than or equal to
d)
Less than or equal to
47.
The following code is used to create a variable and store a value. Why will it NOT work?
my number = 36
a)
The variable can't store a number
b)
A variable name cannot have any spaces
c)
There variable name can't be called my number
d)
The equals symbol should be at the beginning of the line
48.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2
49.

(a)   is smallest individual unit in a program.

50.

Size of the string "Ant Man"

(a)