1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
python in operator and what it reutrns
. It will return True if the element is a member of the sequence and False if it is not.
Python’s range() function creates a set of integers you can iterate over. Describe the arguments you can pass to the range function and how they affect the sequence returned.
range function can pass 1, 2, 3 arguments
range(0,10,2)
{0, 2, 4. 6, 8}
addition of two strings is known as
concatentation
immutable sequence and mutable sequence difference
immutable - cannot be changed
mutable - changed
for ____ in ___________
item sequence
append(item)
adds an item to a list
insert(index, item)
adds the item at the index passed. all other elements are shifted
remove(item)
removes the first occurrence of an item
pop(index)
returns and removes the item at the index
sort()
sorts the list in ascending order
reverse()
reverses the contents of list
count(item)
returns the number of items in a list
index(item)
returns the position of a item in the list
If outfit = (“socks”, “shoes”, “shirt”, “pants”, “bracelet”), what do each of the following return
outfit[2]
outfit[-3:-1]
outfit[2:]
shirt
(shirt, pants, bracelet)
(shirt, pants, bracelet)
names.pop(1)
removes the element at index 1
given str = “Welcome to programming” what does str[:3] + [18:] do?
“Welming”
str = “Mickey Mouse” what does len(str) return
12
output of the print(crazy[1:3]) if crazy = [ ‘xyz’, 123, 9.87, ‘joe’, 45.6 ]?
[123, 9.87]
:3 includes the index before it
if holler = “red rover, red rover…”what would be the output of print(holler[11:21]
red rover
NOT A LIST!! COMMAS ARE INCLUDED