Font size
WorksheetsPython Basics
Total questions: 72
Worksheet time: 36mins
What does the following equation calculate to in Python?
2 + 2 * 3
(a)
Which of the following need to be stored as string data type
Perimeter of a square
Resident of Delhi or not
Name of the student
Address of the student
Which of the following need to be stored as int data type
Number of months in a year
Resident of Delhi or not
Mobile number
Pocket money
Volume of a sphere
Which of the following need to be stored as float data type
Perimeter of a square
Resident of Delhi or not
Name of the student
Pocket money
Volume of a sphere
What kind of data type is this:
cat
String
Integer
Float
N/A
If a=[1,2,3,4], then a[3] is ?
4
3
2
1
Which value is of data type Float?
64
"Cat"
True
0.5
45
String
Integer
Float
Number
Which of the following is the data type possible in python?
int
list
dictionary
All of the above
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?
Perimeter
12
16
an error message
What is the data type of print(type(10))
float
integer
int
none
Which if the values below is a string data type?
firstValue
F
1.0
10 > 3
" "
String
Integer
Float
Number
_____ is a data type that contains a single character such as A, a, Z, z etc.
int
float
char
String
What will be the data type of num1 if the following code is executed?
num1=float(5)
string
int
float
number
Which if the values below is a char data type?
firstValue
F
1.0
10 > 3
Which value is a Boolean?
64
"Cat"
True
0.5
Which if the values below return FALSE if executed?
10 > 3
10 < 3
10 >< 3
10 <> 3
Which variable has a syntax error?
school + "Woodlawn"
bank = 67.80
car = "BMW"
age = 45
Look at the following code:
Length = 50
Width = 30
Area = Length * Width
print (Area)
What is the result of this code?
Area
50
150
an error message
What would the output of this code be?
x = ("Bill")
print(x)
x
"Bill"
Bill
Frank
_____ is a data type that can represent one of two values either True or False such as 1, 0, 2 > 1, 3 < 2.
int
float
char
Boolean
What kind of data type is this:
"30 + 30"
String
Integer
Float
N/A
A variable is a named value that can be changed in the program.
False
True
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?
23
24
age
an error message
Which if the values below is a float data type?
2
2.11
2/4
"2.11"
Look at the following code:
Length = 50
Width = 30
Area = L * W
print (Area)
What is the result of this code?
Area
50
150
an error message
What kind of data type is this:
"55"
String
Integer
Float
N/A
What type of data is this?
num = 3
String
Integer
Float
What would the output be?
x = "4+3"
print(x)
7
7.0
4+3
What is the output for this line of code: print(type(4/2))
<class 'bool'>
<class 'str'>
<class 'int'>
<class 'float'>
Which of the following is a list data type?
[1, "Hello", 5.0, "World"]
(True, 20)
"Greetings"
200.0
_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"
int
float
char
String
78.0
String
Integer
Float
Number
Which if the values below return TRUE if executed?
10 > 3
10 < 3
10 >< 3
10 <> 3
What is the stat type returned for this line of code: type(100/3)
Boolean
string
integer
float
Look at the following code:
age = 23
age = age * 2
print (age)
What is printed?
23
23 * 2
25
46
What data type is the following?
[70, 80, 90, 100]
Integer
Float
List
String
Which is the operator used to DIVIDE?
+
*
/
-
What is a programming language?
Written English
An artificial language used to program a computer
A language used in pseudocode
Machine code
What does the print command do?
Outputs a hard copy of a program to a printer
Outputs a message on screen
Print a hard copy of a flow chart to a printer
Prints out the the commands line by line on the screen
How do we get user input from the keyboard?
input = (What is your name?)
input = What is your name?
output = ("What is your name?")
name=input("What is your name? ")
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
What is the term for an error that a programmer makes in their code so the program won't run?
Program error
Syntax error
Code error
Logic error
What data type would you use to represent the price of an item?
integer
float
Boolean
String
Which of the following variable names is NOT allowed to be used?
first_name
name1
name#1
lastName
In Python3, Whatever you enter as input, the input() function converts it into a string
True
False
In Python3, which functions are used to accept input from the user
input()
raw_input()
rawinput()
string()
What is the word (command) used to display numbers and text on the screen?
input
output
command
What symbol is used in python to assign values to a variable?
equals =
plus +
forward slash /
asterisk *
In python the ' INTEGER data type' can be defined as...?
holds alphanumeric data as text
holds whole numbers
holds numbers with a decimal point
holds either ‘true’ or ‘false’
What will the output be from the following code?print("Hello world!" * 2)
TypeError
Hello world world!
Hello world!Hello world!
Hello world! * 2
What will the output be from the following code?print("Hello world!\nHello world!")
Hello world! Hello world!
Hello world!
SyntaxError
None of all
What will the output be from the following code?print("Hello" + str(2) + "world!")
Hello world! Hello world!
Hello2world!
Hello Hello world! world!
SyntaxError
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
What will the output be from the following code?print(Hello world!)
Hello world!
SyntaxError
Hello world
print(Hello world!)
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
/
\n
\l
n
What will be the output?
Good moning 'Dave'
Good morningDave
Good morning name
Good morning + Dave
Which code produces the following output? Hello
Which of the following functions display an output to the screen?
display()
output()
print()
post()
Which one is NOT a legal variable name?
my_var
_myvar
my-var
Myvar
Which operator can be used to compare two values?
><
==
=
<>
One word is missing from the codes (see picture).
Choose the correct word to ensure the function works.
input
output
variable
Two symbols are missing from the codes (see picture).
Choose the correct symbols to ensure the input function works.
1st blank: "
2nd blank: "
1st blank: #
2nd blank: #
1st blank: !
2nd blank: !
1st blank: (
2nd blank: )
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)
Because variables cannot be longer than 1 word
Because user_input1 and user_input2 is a string
Because input is an invalid function
Because python will always thing that it has to add 1+2
It will work
When we get an input what type of variable is it?Examble:
input_var = input("Input: ")
float
string
int
key
Two symbols are missing from the codes (see picture).
Choose the correct symbols to ensure the input function works.
1st blank: "
2nd blank: "
1st blank: #
2nd blank: #
1st blank: !
2nd blank: !
1st blank: (
2nd blank: )
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)
Because variables cannot be longer than 1 word
Because user_input1 and user_input2 is a string
Because input is an invalid function
Because python will always thing that it has to add 1+2
It will work
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)
1
2
What will the code below print if num1 = 5 and num2 = 8?
num1 = input("Number 1")
num2 = input("Number 2")
print(num1+num2)
85
58
5+8
None of the above
