NEW
Font size
WorksheetsPython basics
Total questions: 22
Worksheet time: 11mins
What is the word (command) used to display numbers and text on the screen?
input
output
display
The number or word we give to a variable
Information
key
value
data
What is a variable?
A box(memory location) where you store values
Data type
Data structure
Value
To display the following on screen
Hello World!
the following command should be used:
print(Hello World!)
print("Hello World!")
print("Hello World" + !)
print"(Hello World!)"
x = 5
y = 6
print("x*y")
The code above displays the following:
11
x*y
30
Syntax Error
Which operator checks if a value is equal to another value?
=
!=
~
==
Which of the following is not a string?
new_var = "True"
new_var = False
new_var = "2.4"
new_var = "5+2j"
Which of these is the best description of a list in Python?
A list is a lot of variables
A list is a lot of numbers
A list is a collection of data that has an order and can be changed
A list is a collection of data that cannot hold duplicated data and cannot be changed
What is the output of Following code?
List = ['spam', 2.0, 5, [10, 20]]
print(List[2])
2.0
[10,20]
5
20
What is the output of the following code?
list = []
list.append(1)
list.append(2.0)
list.append("vk")
print(list)
['vk', 1, 2.0]
Error
[1, 2.0, 'vk']
No Output
What will the output be from the following code? print("Hello" + 2 + "world")
Hello 2 world
Hello2world
TypeError
HelloHelloworld
Joining elements together to make a string is called what?
Connecting
Combining
stringing
Concatenation
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\\
n
\t
\n
To insert an the string "Pedro" in the first position of a the nameList we use
nameList.append("Pedro, 1")
nameList.insert("Pedro",0)
nameList.insert(1, "Pedro")
nameList.insert(0, "Pedro")
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[::-1])
[1,3,5,7,9]
[10, 8, 6,4,2]
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
No Output
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[::-3])
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Compilation error
[8,9,10]
[10, 7, 4, 1]
What will be the output of the following Python code?
x = {4,7,8,8,9}
print(x)
{4,8,8,9,7}
{4,9,8,7}
{4,7,9}
Error
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day!
Friday
Uniform day
Error
What is the output of the following code : print 5//2
2
2.5
2.0
1
What is the output of this expression, 3*1**3?
27
9
3
1
In python,a function is defined using the following keyword
Fun
function_name
func
def
Who is the inventor of python language?
Dennis Ritchie
Bjarne Stroustrup
Guido van Rossum
James Gosling
