Font size
WorksheetsPython basics
Total questions: 60
Worksheet time: 30mins
Python is....................
Open source programming language
Paid programming language
What is the correct name for this symbol?
==
Assignment
Equal to
Greater than
Less than
What will this symbol do?
\n
Not
New line
Does nothing
What does this symbol represent?
>
Less than
Greater than
Equal to
Less than or equal to
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
print("Hello world!\nHello world!")
Hello world!
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
print(Hello world!)
What will be the output?
name = "Dave"
print (name)
Dave
name
"Dave"
(name)
If the coding steps are in the incorrect order, the computer can still execute the program.
True
False
The code you use to receive and input from the keyboard
enter()
add()
receive()
input()
2
0
1
4 / 2
Error
Predict output for the following code snippet.
print('No pain, no gain'.split('a'))
['No pain', ' no gain']
['No p', 'in, no g', 'in']
['No', 'pain,', 'no', 'gain']
['No pai', ', ', 'o gai', '']
What is the name of the built-in command in python to output data?
display
What is a input?
A built-in function that allows us to prompt the user to enter data.
To plug in something.
Data displayed on a screen.
A device.
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
What is the proper syntax for Python comments?
<!-- Python comment -->
<comment> Python comment <comment>
# Python Comment
/* Python Comment */
=
+
==
*
print("Hello world!\nHello world!")
Hello world!
Syntax Error
print("Hello" + str(2) + "world!")
Syntax Error
What does the following code do? myAge = int(myAge)
Converts the variable myAge to a integer
Syntax Error
Converts the variable myAge from a integer to a string
Missing input
Are Double or single quotes used in Python?
Double
Single
Neither
Both work
Which of the following assign the value 50 to a variable x?
x=50
Let x=50
x;=50
x<<50
Python correct naming convention for variables is?
new_user25
NewUser25
25_new_user
25NewUser
NEWUSER25
The output of the program
x = 4
x = "Sally"
print(x)
four
Saly
Sally
4
print("Hello" + 2 + "world")
Print("Hello world!")
Name Error
print("3+4")
print(3+4)
What is the name of the variable in this program?
colour
input
" "
What will be the output for following python programme:
x = 100
y = float(x)
print(y)
200
100.0
100
Can't convert an integer to a floating number.
Which of the following is the slicing operator?
[ ]
{ }
( )
/
What is the output of the following lines of code?
var1 = 12
var1 = 23.4
var1 = "I love AI!"
print(var1)
12
23.4
I love AI!
Error
What is the output from the following lines of code?
a = [2, 4, 8]
a[2] = 6
print(a)
[2, 4, 8]
[2, 6, 8]
[2, 4, 6]
[6, 4, 8]
Which function allows us to add one element to a list at a desired location?
append()
extend()
insert()
pop()
How many parameters are there in the sum() function call below?
sum(1, 3, 5)
0
1
2
3
How many times would the while loop execute?
0
1
2
3
Which is the Python logo?
_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"
int
float
char
String
Which if the values below is an integer data type?
1
1.0
1/2
"1"
Which value is a Boolean?
64
"Cat"
True
0.5
Lists are used to store single item in a single variable.
True
False
List items are indexed, the first item has index [1], the second item has index [2] etc.
True
False
List items are ordered, changeable, and allow duplicate values.
True
False
Lists are created using square brackets:
True
False
what is the correct order?
3,1,6,7,2,4,5
6,3,1,2,4,5,7
3,6,1,2,4,5,7
3,6,2,5,1,4,7
what is the output of the given code?
This car is awesome. The car wins the race
This car is awesome
The car wins the race
Error
choose the correct way to access value 20 from the following tuple
aTuple=("Orange",[10,20,30],(5,15,25))
aTuple[1:2][1]
aTuple[1:2](1)
aTuple[1][1]
What does the following comparison operator “==” represent in Python programming?
Equal to
Assignment
Allocation
Not equal to.
What is the name of the following logical operator?
Returns True if one of the statements is true
(a)
What is the result of the following condition if:
A = 30
B = 21
C = 71
B != A or C < A
True
False
What is a % ?
