Introduction To Python

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:39 PM on 8/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

22 Terms

1
New cards

On what does f-string helps?

on mixing the variables within a string

2
New cards

whats the purpose of writing color[-1] ?

to go to the last element in a list

3
New cards

Whats the output of : 12/4 by knowing both of the numbers are integers?

the output is 3.0

4
New cards

How do we declare a function ?

by writing def

5
New cards
What will this code output?


colors = ['red', 'green', 'blue', 'yellow']
print(colors[2:3])


['blue']

6
New cards

What will this code output?

color = 'pink'
print(color[1:4])

ink

7
New cards

How many values will be extracted from the list

planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter']
print(planets[2:4])

2 values

8
New cards

What will this code output?

cart = ['lamp', 'candles', 'chair', 'carpet']
print(cart[:2])

['lamp', 'candles']

9
New cards

What will this code output?

cart = ['lamp', 'candles', 'chair', 'carpet']
print(cart[2:])

['chair', 'carpet']

10
New cards

What will this code output?

vehicle = 'motorbike'
print(vehicle[5:])

bike

11
New cards

What will this code output?

platform = ['iOS', 'Android', 'Web']
print(platform[:])

['iOS', 'Android', 'Web']

12
New cards

What will this code output?

c = ['$', '£', '€', '¥']
print(c[-1])

PY

¥

13
New cards

What will this code output?

c = ['$', '£', '€', '¥']
print(c[0:-2])

['$', '£']

14
New cards

What will this code output?

c = ['$', '£', '€', '¥']
c[:2] = ['₣', '฿']
print(c)

['₣', '฿', '€', '¥']

15
New cards

How do you reverse a string in Python using slicing?

Use word[::-1] leaving start and stop empty

16
New cards

In string[a:b:c], what do a and b and c represent?

a : start b : stop c : step

17
New cards

What does string[-half:] do?

Takes the last half characters of the string counting from the end

18
New cards

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

19
New cards

What does append() do?

it adds a new element in the last of a list

20
New cards

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

21
New cards

What does pop() do?

it deletes an element from a last

22
New cards

What does find() do?

it finds a specific character or string in another string