Working with Lists, Loop Flashcards
1
Q
Loop & Syntax
A
list=[‘one’,’two’,’three’]
for number in list:
print(number)
2
Q
How to generate a series of numbers?
A
range()
3
Q
How to make a List of Numbers?
A
numb=list(range(1,6))
print(numbers)
[1,2,3,4,5]
4
Q
How to find the min, max and sum of a List of numbers?
A
min/max/sum (list_name)
5
Q
How to Slice a List?
first 3
A
print(list_name[0:3])
6
Q
How to start slicing at the begining of the List?
A
print(list_n [ :5])
print(list_n [5] : )) - from the 6th last number