1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
On what does f-string helps?
on mixing the variables within a string
whats the purpose of writing color[-1] ?
to go to the last element in a list
Whats the output of : 12/4 by knowing both of the numbers are integers?
the output is 3.0
How do we declare a function ?
by writing def
What will this code output?
colors = ['red', 'green', 'blue', 'yellow']
print(colors[2:3])['blue']
What will this code output?
color = 'pink'
print(color[1:4])ink
How many values will be extracted from the list
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter']
print(planets[2:4])2 values
What will this code output?
cart = ['lamp', 'candles', 'chair', 'carpet']
print(cart[:2])['lamp', 'candles']
What will this code output?
cart = ['lamp', 'candles', 'chair', 'carpet']
print(cart[2:])['chair', 'carpet']
What will this code output?
vehicle = 'motorbike'
print(vehicle[5:])bike
What will this code output?
platform = ['iOS', 'Android', 'Web']
print(platform[:])['iOS', 'Android', 'Web']
What will this code output?
c = ['$', '£', '€', '¥']
print(c[-1])PY
¥
What will this code output?
c = ['$', '£', '€', '¥']
print(c[0:-2])['$', '£']
What will this code output?
c = ['$', '£', '€', '¥']
c[:2] = ['₣', '฿']
print(c)['₣', '฿', '€', '¥']
How do you reverse a string in Python using slicing?
Use word[::-1] leaving start and stop empty
In string[a:b:c], what do a and b and c represent?
a : start b : stop c : step
What does string[-half:] do?
Takes the last half characters of the string counting from the end
In lists, the for loop is required why?
Example:
#installed games
games = [
{ "name":"Soccer", "id": 0},
{ "name":"Tic Tac Toe","id":1},
{ "name": "Snake","id":2},
{"name": "Puzzle","id": 3},
{"name": "Rally","id":4},
]
choice = int(input("Choose a game: "))
for game in games:
if choice == game["id"]:
print(game['name'])
break
else:
print("game not found")
bcs you cant check all the elements without it
What does append() do?
it adds a new element in the last of a list
What does insert() do?
Example :
numbers = [1, 2, 4, 5]
numbers.insert(position, variable) it adds an element in a specific position in a list
What does pop() do?
it deletes an element from a last
What does find() do?
it finds a specific character or string in another string