wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 72

Worksheet time: 36mins

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