wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 102

Worksheet time: 2hrs 42mins

Name
Class
Date
1.

What does the following equation calculate to in Python?

2 + 2 * 3

(a)  

2.

Which of the following need to be stored as string data type

a)

Perimeter of a square

b)

Resident of Delhi or not

c)

Name of the student

d)

Address of the student

3.

Which of the following need to be stored as int data type

a)

Number of months in a year

b)

Resident of Delhi or not

c)

Mobile number

d)

Pocket money

e)

Volume of a sphere

4.

Which of the following need to be stored as float data type

a)

Perimeter of a square

b)

Resident of Delhi or not

c)

Name of the student

d)

Pocket money

e)

Volume of a sphere

5.

What kind of data type is this:

cat

a)

String

b)

Integer

c)

Float

d)

N/A

6.

If a=[1,2,3,4], then a[3] is ?

a)

4

b)

3

c)

2

d)

1

7.

Which value is of data type Float?

a)

64

b)

"Cat"

c)

True

d)

0.5

8.

45

a)

String

b)

Integer

c)

Float

d)

Number

9.

Which of the following is the data type possible in python?

a)

int

b)

list

c)

dictionary

d)

All of the above

10.

Look at the following code:

Length = input ("Length: ")

Width = input ("Width: ")

Area = Length * Width

Perimeter = 2 * (Length + Width)

print (Perimeter)


What is the result of this code if the user inputed 2 then 4?

a)

Perimeter

b)

12

c)

16

d)

an error message

11.

What is the data type of print(type(10))

a)

float

b)

integer

c)

int

d)

none

12.

Which if the values below is a string data type?

a)

firstValue

b)

F

c)

1.0

d)

10 > 3

13.

" "

a)

String

b)

Integer

c)

Float

d)

Number

14.

_____ is a data type that contains a single character such as A, a, Z, z etc.

a)

int

b)

float

c)

char

d)

String

15.

What will be the data type of num1 if the following code is executed?

num1=float(5)

a)

string

b)

int

c)

float

d)

number

16.

Which if the values below is a char data type?

a)

firstValue

b)

F

c)

1.0

d)

10 > 3

17.

Which value is a Boolean?

a)

64

b)

"Cat"

c)

True

d)

0.5

18.

Which if the values below return FALSE if executed?

a)

10 > 3

b)

10 < 3

c)

10 >< 3

d)

10 <> 3

19.

Which variable has a syntax error?

a)

school + "Woodlawn"

b)

bank = 67.80

c)

car = "BMW"

d)

age = 45

20.

Look at the following code:

Length = 50

Width = 30

Area = Length * Width

print (Area)


What is the result of this code?

a)

Area

b)

50

c)

150

d)

an error message

21.

What would the output of this code be?

x = ("Bill")

print(x)

a)

x

b)

"Bill"

c)

Bill

d)

Frank

22.

_____ is a data type that can represent one of two values either True or False such as 1, 0, 2 > 1, 3 < 2.

a)

int

b)

float

c)

char

d)

Boolean

23.

What kind of data type is this:

"30 + 30"

a)

String

b)

Integer

c)

Float

d)

N/A

24.

A variable is a named value that can be changed in the program.

a)

False

b)

True

25.

Look at the following code:

age = int(input ("What is your age? "))

age = age + 1

print (age)


If the user inputs 23, what is the result of the code?

a)

23

b)

24

c)

age

d)

an error message

26.

Which if the values below is a float data type?

a)

2

b)

2.11

c)

2/4

d)

"2.11"

27.

Look at the following code:

Length = 50

Width = 30

Area = L * W

print (Area)


What is the result of this code?

a)

Area

b)

50

c)

150

d)

an error message

28.

What kind of data type is this:

"55"

a)

String

b)

Integer

c)

Float

d)

N/A

29.

What type of data is this?

num = 3

a)

String

b)

Integer

c)

Float

30.

What would the output be?

x = "4+3"

print(x)

a)

7

b)

7.0

c)

4+3

31.

What is the output for this line of code: print(type(4/2))

a)

<class 'bool'>

b)

<class 'str'>

c)

<class 'int'>

d)

<class 'float'>

32.

Which of the following is a list data type?

a)

[1, "Hello", 5.0, "World"]

b)

(True, 20)

c)

"Greetings"

d)

200.0

33.

_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"

a)

int

b)

float

c)

char

d)

String

34.

78.0

a)

String

b)

Integer

c)

Float

d)

Number

35.

Which if the values below return TRUE if executed?

a)

10 > 3

b)

10 < 3

c)

10 >< 3

d)

10 <> 3

36.

What is the stat type returned for this line of code: type(100/3)

a)

Boolean

b)

string

c)

integer

d)

float

37.

Look at the following code:

age = 23

age = age * 2

print (age)


What is printed?

a)

23

b)

23 * 2

c)

25

d)

46

38.

What data type is the following?

[70, 80, 90, 100]

a)

Integer

b)

Float

c)

List

d)

String

39.

Which is the operator used to DIVIDE?

a)

+

b)

*

c)

/

d)

-

40.

What is a programming language?

a)

Written English

b)

An artificial language used to program a computer

c)

A language used in pseudocode

d)

Machine code

41.

What does the print command do?

a)

Outputs a hard copy of a program to a printer

b)

Outputs a message on screen

c)

Print a hard copy of a flow chart to a printer

d)

Prints out the the commands line by line on the screen

42.

How do we get user input from the keyboard?

a)

input = (What is your name?)

b)

input = What is your name?

c)

output = ("What is your name?")

d)

name=input("What is your name? ")

43.
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
44.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

45.

What is the term for an error that a programmer makes in their code so the program won't run?

a)

Program error

b)

Syntax error

c)

Code error

d)

Logic error

46.
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")
47.

What data type would you use to represent the price of an item?

a)

integer

b)

float

c)

Boolean

d)

String

48.

Which of the following variable names is NOT allowed to be used?

a)

first_name

b)

name1

c)

name#1

d)

lastName

49.

In Python3, Whatever you enter as input, the input() function converts it into a string

a)

True

b)

False

50.

In Python3, which functions are used to accept input from the user

a)

input()

b)

raw_input()

c)

rawinput()

d)

string()

51.

What is the word (command) used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

52.

What symbol is used in python to assign values to a variable?

a)

equals =

b)

plus +

c)

forward slash /

d)

asterisk *

53.

In python the ' INTEGER data type' can be defined as...?

a)

holds alphanumeric data as text

b)

holds whole numbers

c)

holds numbers with a decimal point

d)

holds either ‘true’ or ‘false’

54.

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

55.

What will the output be from the following code?print("Hello world!\nHello world!")

a)

Hello world! Hello world!

b)

Hello world!

c)

SyntaxError

d)

None of all

56.

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)

SyntaxError

57.

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

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

58.

What will the output be from the following code?print(Hello world!)

a)

Hello world!

b)

SyntaxError

c)

Hello world

d)

print(Hello world!)

59.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

/

b)

\n

c)

\l

d)

n

60.

What will be the output?

a)

Good moning 'Dave'

b)

Good morningDave

c)

Good morning name

d)

Good morning + Dave

61.

Which code produces the following output? Hello

a)
b)
c)
d)
62.

Which of the following functions display an output to the screen?

a)

display()

b)

output()

c)

print()

d)

post()

63.

Which one is NOT a legal variable name?

a)

my_var

b)

_myvar

c)

my-var

d)

Myvar

64.

Which operator can be used to compare two values?

a)

><

b)

==

c)

=

d)

<>

65.

One word is missing from the codes (see picture).

Choose the correct word to ensure the function works.

a)

input

b)

output

c)

variable

d)

print

66.

Two symbols are missing from the codes (see picture).

Choose the correct symbols to ensure the input function works.

a)

1st blank: "

2nd blank: "

b)

1st blank: #

2nd blank: #

c)

1st blank: !

2nd blank: !

d)

1st blank: (

2nd blank: )

67.

why will the following script won't work?

user_input1 = input("Enter a number: ")

user_input2 = input("Enter a second number: ")


print(user_input1 + user_input2)

a)

Because variables cannot be longer than 1 word

b)

Because user_input1 and user_input2 is a string

c)

Because input is an invalid function

d)

Because python will always thing that it has to add 1+2

e)

It will work

68.

When we get an input what type of variable is it?Examble:

input_var = input("Input: ")

a)

float

b)

string

c)

int

d)

key

69.

Two symbols are missing from the codes (see picture).

Choose the correct symbols to ensure the input function works.

a)

1st blank: "

2nd blank: "

b)

1st blank: #

2nd blank: #

c)

1st blank: !

2nd blank: !

d)

1st blank: (

2nd blank: )

70.

why will the following script won't work?

user_input1 = input("Enter a number: ")

user_input2 = input("Enter a second number: ")


print(user_input1 + user_input2)

a)

Because variables cannot be longer than 1 word

b)

Because user_input1 and user_input2 is a string

c)

Because input is an invalid function

d)

Because python will always thing that it has to add 1+2

e)

It will work

71.

Which code will work?

1) num1 = input("Number 1")

num2 = input("Number 2")

print(num1+num2)


2)num1 = float(input("Number1")

num2= float(input("Number 2")

print(num1+num2)

a)

1

b)

2

72.

What will the code below print if num1 = 5 and num2 = 8?

num1 = input("Number 1")

num2 = input("Number 2")

print(num1+num2)

a)

85

b)

58

c)

5+8

d)

None of the above

73.

Operators are used to perform operations on values and variables .The value the operator operates on is known as- --------------

a)

Operands

b)

symbols

74.

In Python Comparison operators are also called -----------------------

a)

Relational operators

b)

Operand

c)

Boolean value

75.

-------------------they compares the operands on either side (the values) and determine the relation between them

a)

Relational operators

b)

Comparison operators

c)

All that mentioned

76.

•The output of the comparison results in ----------------according to the condition.

a)

a Boolean value

b)

returns True or False

c)

All that mentioned

77.

-------------------they compares the operands on either side (the values) and determine the relation between them

a)

logical operators

b)

Comparison operators

c)

All that mentioned

d)

Arithmetic operators

78.

Checks whether two operands are equal we use ---------------operator

a)

==

b)

=

c)

>=

79.

Checks whether two operands are not equal we use ---------------operator

a)

==

b)

!=

c)

>=

80.

Use the correct comparison operator to check if 5 is Lesser than or equal to 10.

a)

<=

b)

!=

c)

>=

81.

Check this Python program then choose the output of these Comparison operators A or B

a)

A

b)

B

82.

In Python, Logical operators are using-----------

a)

Symbols

b)

Words

83.

Logical ---------------operator : Logical operator returns True if both the operands are True else it returns False

a)

AND

b)

OR

c)

Not

84.

Logical AND operator returns True if both the operands are True else it returns False.

The output of this Python program will be

a)

True

b)

False

85.

Logical OR operator : returns True if either (at least) of the operands is True

The output of this Python program will be

a)

True

b)

False

86.

Logical not operator : work with the single Boolean value. If the Boolean value is True it returns False and vice-versa Reverse the result

a)

True

b)

False

87.

Use the correct logical operator to check if at least one of two statements is True

a)

AND

b)

OR

c)

Not

88.

Use the correct logical operator to Reverse the result of the statements

a)

AND

b)

OR

c)

Not

89.

A truth table: Is a breakdown of a logic function by listing all possible values The function can attain and their results

a)

True

b)

False

90.

What will be the result for this program


If the user entered 8

a)

True

b)

False

91.

Decision making is required when we want to execute a code only if a certain condition is satisfied.


The ----------- is used in Python for decision making

a)

if statement(s)

b)

while statement(s)

92.

In Python, the selection statements are also known as decision making statements or branching statements.

a)

True

b)

False

93.

In Python to check for multiple expressions we use ----------

a)

if...elif...else Statement

b)

if...else Statement

c)

If statement

94.

What will this code print?

a)

access denied

b)

access granted

c)

error

95.

This Python program is missing an indentation to be correct. it should be inserted at start of line ---------

a)

1

b)

2

96.

In Python if...else Statement the body of else will be executed If the condition is

a)

True

b)

False

97.

In Python if...elif...else Statement . The if block can have only one else block. But it can have multiple elif blocks

a)

True

b)

False

98.

The output of this if statement is --------

a)

a has value zero(0)

b)

a is not equal to zero

99.

In this if Statement which block will be executed ----------

a)

if block (line 3)

b)

else block (line 5)

100.

In this if Statement which block will be executed ----------

a)

if block (line 4)

b)

else block (line 6)

101.

In this if Statement which block will be executed ----------

a)

if block (line 3)

b)

else block (line 5)

102.

What will be the output of this if statement if the user entered : 10

a)

In rang

b)

negative

c)

out of range