LV - Python

studied byStudied by 7 people
5.0(2)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 19

flashcard set

Earn XP

Description and Tags

20 Terms

1

indexing

making and printing the list:

listFood = [“chocolate”, “cheese”, “fruit”]

print(listFood[1])

New cards
2

slicing (start, stop, step)

start stop step refers to the positions

[start:stop:step]

start = the index number the index begins

stop = the index number the index ends

step = the jump range

New cards
3

append()

to add an item to the end of a list:

listNames.append(“sally”)

New cards
4

insert()

to insert an item into a specific place on the list:

listNames.insert(2, “elisa”)

New cards
5

remove()

to remove an item from a list:

listNames.remove(“penelope”)

New cards
6

pop()

takes out an item at a certain index in a list:

listNames.pop(3)

New cards
7

del list[]

deletes permanently the item at a particular index:

del listNames[4]

New cards
8

sort()

sorts a list into ascending order:

listNames.sort()

New cards
9

len()

prints out the number of terms in a list:

print(len(listNames))

New cards
10

index()

returns the number where the item appears in the list:

print(listNames.index(“freya”))

New cards
11

using “in”

“in” is used to say if something is in the list then something else should happen:

if “elsa” in listNames:

New cards
12

validation - range

user is asked to input something between a certain range:

numRange = int(input(“Please enter a number between 11 and 18”))

New cards
13

validation - lookup

user is asked to input something from a store of data:

country = input(“Please enter a country from the list above”)

New cards
14

“==”

to compare terms:

if item == “a”:

New cards
15

nested for loops

a loop inside a loop:

x = [1, 2]

y = [4, 5]

for i in x:

for j in y:

print(i, j)

New cards
16

when do you use a nested loop?

if you have multiple lists that you want to do something with, or if you have a list within a list (a nested list)

New cards
17

def functionName():

the way of naming a function:

def addTwoNumbers():

print(2+2)

New cards
18

Formal parameters

items in brackets which are variables:

def addTwoGivenNumbers(num1 + num2):

print(num1+num2)

New cards
19

Actual parameters

items in brackets which are actual things:

addTwoNumbers(6+7):

print(6+7)

New cards
20

return functions

instead of printing, it is returning something:

def returnAdditionOfTwoNumbers(num1+num2):

return num1+num2

New cards

Explore top notes

note Note
studied byStudied by 14 people
863 days ago
5.0(1)
note Note
studied byStudied by 269 people
710 days ago
5.0(3)
note Note
studied byStudied by 141 people
1031 days ago
4.3(7)
note Note
studied byStudied by 4 people
443 days ago
5.0(1)
note Note
studied byStudied by 13 people
847 days ago
5.0(1)
note Note
studied byStudied by 20 people
863 days ago
5.0(1)
note Note
studied byStudied by 5 people
13 days ago
5.0(1)
note Note
studied byStudied by 18 people
850 days ago
5.0(1)

Explore top flashcards

flashcards Flashcard (37)
studied byStudied by 69 people
316 days ago
5.0(2)
flashcards Flashcard (30)
studied byStudied by 2 people
780 days ago
5.0(1)
flashcards Flashcard (33)
studied byStudied by 239 people
738 days ago
4.2(15)
flashcards Flashcard (33)
studied byStudied by 6 people
63 days ago
5.0(1)
flashcards Flashcard (27)
studied byStudied by 5 people
450 days ago
5.0(1)
flashcards Flashcard (22)
studied byStudied by 6 people
842 days ago
5.0(1)
flashcards Flashcard (35)
studied byStudied by 15 people
814 days ago
4.0(1)
flashcards Flashcard (292)
studied byStudied by 23 people
192 days ago
5.0(2)
robot