NEW
Font size
WorksheetsIntermediate Python
Total questions: 15
Worksheet time: 8mins
Your Mindset Right now
Create a variable named bike and assign the value Kawasaki H2R to it
bike= Kawasaki H2R
"bike" = Kawasaki
H2R bike= "Kawasaki H2R"
"KawasakiH2R"= bike
Create a variable named x and assign the value of integer 50 to it
x="50"
x: 50
"x"=50
x=50
Display the sum of 5 + 10, using two variables: x and y
x=y y = 10
print(x +y)
x=5 y = x
print(x +y)
x=10 y =5
print(x +y)
x=5 y =10
print(x +y)
Select the illegal variable name
2my-first_name = "John"
my-firstname = "John"
__my-first_name = "John"
my2-first_name = "John"
What is used to print the length of a string
len()
length()
type.legth()
fulllength()
What can we use to get the first character of a string txt= "Banana"
x=txt(0)
x=txt(1)
x=txt[0]
x=txt[1]
What can we use to get the characters from index 2 to index 4 (llo) in txt = "Hello, World"
Options
x= txt[2:4]
x= txt[1:4]
x= txt[2:5]
x= txt[2:6]
Select the right syntax for the if condition
a=10 b=20 if a is greater than b: print("Hello World")
a=10 b=20 if a>b: print("Hello World")
a=10 b=20 if a>b; print("Hello World")
Fill in the blank if a> b: print("True") _____: print("False")
otherwise:
then:
else:
elif:
Select the right syntax to create a function called my_function
def my_function:
define my_function:
func my_function;
create funct my_function;
Inside a function with two parameters, print the first parameter. def my_function(fname, lname): print(________)
my_function
fname
lastname
lname
What will be the output of the following program: fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": print(x)
cherry
apple
apple cherry
banana
The following code will stop the loop if i is 3 Fill in the blanks to perform the same i = 1 ______ i < 6: if i == 3: break i += 1
do while
for
if
while
What will be the output for the following code: for x in range(6): print(x)
0 1 2 3 4 5 6
1 2 3 4 5 6
0 1 2 3 4 5
1 2 3 4 5
