Home
Explore
Exams
Login
Get started
Home
Engineering
Computer Science
LV - Python
5.0
(2)
Rate it
Studied by 9 people
View linked note
Call Kai
Learn
Practice Test
Spaced Repetition
Match
Flashcards
Knowt Play
Card Sorting
1/19
Earn XP
Description and Tags
Computer Science
All Modes
Learn
Practice Test
Matching
Spaced Repetition
Call with Kai
Last updated 10:48 AM on 5/15/23
Update
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
No analytics yet
Send a link to your students to track their progress
20 Terms
View all (20)
Star these 20
1
New cards
indexing
making and printing the list:
listFood = \[“chocolate”, “cheese”, “fruit”\]
print(listFood\[1\])
2
New cards
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
3
New cards
append()
to add an item to the end of a list:
listNames.append(“sally”)
4
New cards
insert()
to insert an item into a specific place on the list:
listNames.insert(2, “elisa”)
5
New cards
remove()
to remove an item from a list:
listNames.remove(“penelope”)
6
New cards
pop()
takes out an item at a certain index in a list:
listNames.pop(3)
7
New cards
del list\[\]
deletes permanently the item at a particular index:
del listNames\[4\]
8
New cards
sort()
sorts a list into ascending order:
listNames.sort()
9
New cards
len()
prints out the number of terms in a list:
print(len(listNames))
10
New cards
index()
returns the number where the item appears in the list:
print(listNames.index(“freya”))
11
New cards
using “in”
“in” is used to say if something is in the list then something else should happen:
if “elsa” in listNames:
12
New cards
validation - range
user is asked to input something between a certain range:
numRange = int(input(“Please enter a number between 11 and 18”))
13
New cards
validation - lookup
user is asked to input something from a store of data:
country = input(“Please enter a country from the list above”)
14
New cards
“==”
to compare terms:
if item == “a”:
15
New cards
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)
16
New cards
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)
17
New cards
def functionName():
the way of naming a function:
def addTwoNumbers():
print(2+2)
18
New cards
Formal parameters
items in brackets which are variables:
def addTwoGivenNumbers(num1 + num2):
print(num1+num2)
19
New cards
Actual parameters
items in brackets which are actual things:
addTwoNumbers(6+7):
print(6+7)
20
New cards
return functions
instead of printing, it is returning something:
def returnAdditionOfTwoNumbers(num1+num2):
return num1+num2
Explore top notes
Unit 5: Period 5: 1844-1877
Updated 1038d ago
0.0
(0)
Module 3 Summary
Updated 318d ago
0.0
(0)
Principles of Life, Chapter 12 Reading
Updated 905d ago
0.0
(0)
Unit 4: Magnetic Fields
Updated 1071d ago
0.0
(0)
Untitled
Updated 1112d ago
0.0
(0)
Cold War
Updated 1261d ago
0.0
(0)
Chapter 12- The Cell Cycle
Updated 1171d ago
0.0
(0)
AP Precalculus Ultimate Guide
Updated 102d ago
0.0
(0)
Unit 5: Period 5: 1844-1877
Updated 1038d ago
0.0
(0)
Module 3 Summary
Updated 318d ago
0.0
(0)
Principles of Life, Chapter 12 Reading
Updated 905d ago
0.0
(0)
Unit 4: Magnetic Fields
Updated 1071d ago
0.0
(0)
Untitled
Updated 1112d ago
0.0
(0)
Cold War
Updated 1261d ago
0.0
(0)
Chapter 12- The Cell Cycle
Updated 1171d ago
0.0
(0)
AP Precalculus Ultimate Guide
Updated 102d ago
0.0
(0)
Explore top flashcards
The Great War Study Guide
48
Updated 1079d ago
0.0
(0)
Unit 2 Study Guide
31
Updated 485d ago
0.0
(0)
MMW 11: Chang midterm
143
Updated 492d ago
0.0
(0)
Los deportes
22
Updated 356d ago
0.0
(0)
ch 13 woobie
25
Updated 1088d ago
0.0
(0)
Spanish 2: La Salud
49
Updated 836d ago
0.0
(0)
Mechanics of Breathing
30
Updated 1197d ago
0.0
(0)
Lecture 4: Surgery of the Spleen
38
Updated 24d ago
0.0
(0)
The Great War Study Guide
48
Updated 1079d ago
0.0
(0)
Unit 2 Study Guide
31
Updated 485d ago
0.0
(0)
MMW 11: Chang midterm
143
Updated 492d ago
0.0
(0)
Los deportes
22
Updated 356d ago
0.0
(0)
ch 13 woobie
25
Updated 1088d ago
0.0
(0)
Spanish 2: La Salud
49
Updated 836d ago
0.0
(0)
Mechanics of Breathing
30
Updated 1197d ago
0.0
(0)
Lecture 4: Surgery of the Spleen
38
Updated 24d ago
0.0
(0)