wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Getting to know Python Programming :Quiz

Total questions: 56

Worksheet time: 29mins

Name
Class
Date
1.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
2.
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’
3.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
4.

Challenge Question

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

a)

holds alphanumerical data

b)

holds whole numbers

c)

holds a number with a decimal point

d)

holds either true or false

5.
What is the correct definition for a VARIABLE?
a)
a changeable value, such as a score in a computer game.
b)
a value that cannot be changed
6.

What data type would be used for storing someone's telephone numbers?

a)

Float (using a decimal point)

b)

Integer (just whole numbers)

c)

String (alphanumerical data)

d)

Boolean (true or false)

7.

If we needed to store information such as a POSTCODE in PYTHON, what data type would we use?

a)

String (alphanumerical)

b)

Float (decimal point)

c)

Boolean (true or false)

d)

Integer (Whole numbers)

8.
What is the correct definition for 'pseudo code?'
a)
a notation resembling a complex programming language, used in program design.
b)
a notation resembling a simplified programming language, used in program design.
9.
what is the code for a STRING in python?
a)
str
b)
stri
c)
stg
10.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
11.
What is the output from the following code?print ("hello world")
a)
Hello World
b)
hello world
c)
print hello world
12.
What best defines an IF statement in python?
a)
Is an embedded string with a variable
b)
An IF statement checks to see if a statement is true or false and then does one of two things depending on the result.
13.
What function would I use to display text?
a)
sum
b)
import
c)
print
d)
display
14.
What does a hashtag represent when using Python?
a)
red text
b)
float
c)
comment
d)
integer
15.
Where do you run your code?
a)
console
b)
interrupter
c)
compiler
d)
editor
16.

What is missing from this program – print(my name is , firstname)?

a)

‘‘ ’’

b)

: :

c)

??

d)

*** ***

17.
To get the users input what function do we use?
a)
Input
b)
input<> 
c)
input() 
d)
INPUT()
18.
What does int() represent?
a)
internet
b)
input
c)
intel
d)
integer
19.
What is a float?
a)
decimal number
b)
whole number
c)
half a number
d)
a fraction
20.
What is an integer?
a)
half a number
b)
a fraction
c)
decimal number
d)
whole number
21.
Choose what * performs.
a)
multiplication
b)
addition
c)
division
d)
subtraction
22.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
23.

Challenge Question

What are these () called in programming?

a)

brackets

b)

quotation marks

c)

half circles

d)

parenthesis

24.
What three things make up an if statement?
a)
if, egg, else
b)
if, elif, else
c)
if, elif, egg
d)
if, excited, scream
25.
What is wrong with this code?

print"What football team do you support?"
a)
no quotation marks
b)
no parentheses
c)
no commas
d)
no capital letters
26.
What is wrong with this code?

if answer == (“Man United”)
a)
no quotation marks
b)
no parentheses
c)
no capital letters
d)
No colon
27.

What does the equal sign mean in this code?


team = input(“Enter a team”)

a)

variable holds data

b)

variable is equal to

c)

variable is greater than

d)

variable should be an integer

28.
What does “==” represent in Python programming?
a)
less than
b)
equal to
c)
greater than
d)
not equal to
29.
What does “input()” represent in this code?

colour = input(“Enter a colour”)
a)
prompts the user to enter an input
b)
it gives the user a colour
c)
it turns the text that colour
30.

What is “team” in this line of code?

team = input()

a)

constant

b)

string

c)

variable

d)

Integer

31.

Which has integer data type?

a)

Phone number

b)

Post Code

c)

Student ID

d)

Number of students in the class

32.

There are 40 students in a classroom. We would like to get all students whose name starts with "A". Which looping is suitable?

a)

For loop

b)

While loop

33.

Given a statement "All swan are white". To falsify this statement, you need to travel around the world and find at least one non-white swan. Which one is a indispensable command in your coding?

a)

For loop

b)

While loop

c)

Conditional statement

34.

Patients visit hospital everyday. You want to count for the "new patients" for each day. Which one is not necessary?

a)

Set

b)

While loop

c)

For loop

d)

Set difference

35.

What will be the output if the user enters 'child' and 'friday'?

a)

£4.00

b)

£2.50

c)

There will be a syntax error

d)

£2.00

36.

What is the process of identifying and fixing errors in your code?

a)

Rebugging

b)

Syntax Solving

c)

Debugging

d)

Abstraction

37.

Read the code

firstname = input()

surname=input()

fullname = firstname + " " + surname

print(fullname)

a)

Sarah Barnes

b)

Sarah

c)

Barnes

d)

SarahBarnes

38.

Challenge Questions

What can be used to create a line break in printed text?

a)

\N

b)

\\n

c)

/n

d)

\n

39.

What is an Algorithm?

a)

A chart showing the flow of a series of events

b)

Step-by-step instructions used to solve a problem

c)

A decision arrived at by following instructions

d)

A computer program that follows a chart

40.

What are algorithms used for?

a)

To plan out the solution to a problem

b)

As a platform to program a solution

c)

To test a solution to a problem

41.

Which of these is NOT a symbol of a flowchart

a)

Decision

b)

Sequence

c)

Process

d)

Input/output

e)

Start or End

42.

How do you insert COMMENTS in Python code?

a)

#This is a comment

b)

/* This is a comment */

c)

// This is a comment

43.

What is the correct file extension for Python files?

a)

.pyt

b)

.py

c)

.pyth

d)

.pt

44.

What does != mean?

a)

equal to

b)

Not equal to

c)

less than

d)

greater than

45.

Fill in the gaps. (2 answers)

itemPrice = _________(input("input item price £"))
quantity = int(input("quantity bought "))

discount = 0
totalCost = quantity * itemPrice
if totalCost ______ 50 :
  discount = totalCost * 0.1
  toPay = totalCost - discount
  print ("You qualify for a discount of £", discount)
else : toPay = totalCost
print ("amount to pay is £", toPay)

a)

integer

b)

Float

c)

>=

d)

==

46.

Which method can be used to return a string in upper case letters?

a)

uppercase()

b)

toUpperCase()

c)

upperCase(

d)

upper()

47.

What is a correct syntax to return the first character in a string? such as Sarah would be S

a)

print ("Your initials are," firstname[0])

b)

print( "firstname"[1])

c)

x = sub("firstname", 0, 1)

d)

print(firstname[0])

48.

Which of the following could be used as a variable name.( select 2)

a)

firstname

b)

print

c)

age

d)

class

49.

Which of the following could be used as a variable name.( select 2)

a)

firstname

b)

print

c)

age

d)

class

50.

_______throw != 6:

input("No good - press Enter to throw again... ")

throw = random.randint(1, 6)

print ("You threw",throw)

count += 1 #a short way or writing count = count + 1

print("That took "+ str(count) +" throws")


What is the missing code

a)

Loop

b)

Condition

c)

While

d)

Neither

51.

Which search using the following approach


The list is examined one at a time from the beginning

a)

Linear

b)

Binary

52.

Which search uses the following method


finds midpoint in range, established number and then continued to bisection each range until number is found.

a)

Linear

b)

Binary

53.

Missing code line 8


attempts = 0

while attempts != 3:

password = input("Enter your password: ")

attempts = attempts + 1

if password == "abcd1234":

print("Access Granted")

attempts = 3 #What happens if this statement is left out?

line 8 ________:

print("password incorrect")

if password != "abcd1234":

print("You are locked out")

a)

if

b)

else

c)

elif

d)

then

54.

Missing code line 6


if speed <= 5:

print("check value entered is correct")

else:

if speed >= 75:

print("Issue speeding fine")

line 6 _____________ speed > 60:

print("Issue warning")

else:

print("No action")

a)

while

b)

if

c)

elif

d)

else

55.

Missing code line 2


grade = int(input("Enter your grade: "))

line 2_____grade >= 80:

print("Distinction")

elif grade >= 70:

print("Merit")

elif grade >= 60:

print("Pass")

else:

print("Fail")

a)

while

b)

if

c)

elif

d)

else

56.

how can you reference a function


This is for a dice scenario


import random

a)

random.randint(1,6)

b)

variable.random[6]

c)

random(1,6)

d)

random.ranint[1,6]