WorksheetsPython basics
Total questions: 60
Worksheet time: 31mins
name = 'Dave'
print (name)
Which is the Python logo?
What is a input?
A function that allows us to ask the user to enter some data.
To plug in something.
Data displayed on a screen.
A function
What is a output?
A piece of data that is shown on the screen.
Data that the user enters
An output
A orange
What function is used to output a message in python?
print("")
input=name
name=input
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
What is pseudocode?
A planning tool that resembles code but is not code used for humans.
Syntax code
A programming language.
A pastry.
Why would you use a loop?
To repeat a piece of code
To create a loop
To input data
print(3+4)
print("3+4")
print(3*4+5)
Which is the correct operator for power xy
x^y
x**y
x^^y
None of these
What is the answer to this expression, 22%3 is
7
1
0
5
Which one of theses is floor division
/
//
%
None of theses
What is the order of precedence in Python?
i. Parenthesis
ii. Exponential
iii. Multiplication
iv. Division
v. Addition
vi. Subtraction
i, ii, iii, iv, v, vi
ii, i, iii, iv, v, vi
ii, i, iv, iii, v, vi
i, ii, iii, vi, v, iv
Which of the following is true for variable names in python?
Unlimited Length
all private members must have leading and trailing underscores
underscores and ampersand are only two special characters allowed
None of these
Data type for a whole number
Float
Boolean
Integer
String
A Python data type that holds positive and negative whole numbers
String
int
str
input
The Boolean operator that returns true if EITHER of its operands are true
and
or
not
equal
print(boolean(None, "String", False, "False", 0,"value")
What is the output?
False, True, True, False, False, True
False, True, False, True, False, True
True, True, False, False, True, False
False, False, True, True, False, True
Which of the following pieces of code defines a list of all the numbers from 4 to 12?
range(4,12)
range(4, 13)
range( 3,12)
range(3, 13)
Why did Guido van Rossum call his programming language Python?
He thinks Pythons were cool
He couldn't think of anything else
A friend suggested it
He loves Monty Python
What is concatenation?
Replacing a string variable with another string variable
Combining two variables such as first name and last name
One of the food options in the canteen on Friday
A large collection of cats in an open space
What does != represent?
Possibly equal to
Not equal to
Check for error
Don't assign a value
people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
Which of the below operators can be used to compare two numbers
==
><
=
How is a block of code defined in Python ?
with indentation
with paranthesis
with curly braces
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
List items have an index number. In the following list, which item has the index number of 3?
["Barry", "Harry", "Jesse", "John", "Peter", "Harry"]
"Barry"
"Harry"
"Jesse"
"John"
name = “Alison”
number = len(name)
print(number)
for number in range(6):
print(number)
Valid variable names are:
current-balance
Current Balance
account4
4account
current_balance
The symbols >>> are called
much greater than
the interactive prompt
command
string
When designating a variable, if more than one word is used, there needs to be a(n) ____________________ between the words
space
hyphen (-)
hashtag (#)
underscore (_)
Which code prints the output [3,7,8] for a given list -
[ [1,2,3] , [5,6,7] , [0,9,8] ]
[i[2] for i in list]
[i(2) for i in list]
[i[3] for i in list]
(i(3) for i in list)
What will be the output of the following Python code?
str1 = 'hello'
str1=str1+2
hello2
Error
hello
hello 2
What is the default data type of input()?
string
int
depends what is entered
list
Is this a valid example of the Input-Process-Output Model?
Input: Text and numbers typed on keyboard.
Process: Calculations performed in a spreadsheet.
Output: Bank record.
Yes.
No.
I don't know.
