unit 3 compsci

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

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.  

2
New cards
  1. 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

3
New cards

range(0,10,2)

{0, 2, 4. 6, 8}

4
New cards

addition of two strings is known as

concatentation

5
New cards

immutable sequence and mutable sequence difference

immutable - cannot be changed

mutable - changed

6
New cards

for ____ in ___________

item sequence

7
New cards

append(item)

adds an item to a list

8
New cards

insert(index, item)

adds the item at the index passed. all other elements are shifted

9
New cards

remove(item)

removes the first occurrence of an item

10
New cards

pop(index)

returns and removes the item at the index

11
New cards

sort()

sorts the list in ascending order

12
New cards

reverse()

reverses the contents of list

13
New cards

count(item)

returns the number of items in a list

14
New cards

index(item)

returns the position of a item in the list

15
New cards
  1. 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)

16
New cards

names.pop(1)

removes the element at index 1

17
New cards

given str = “Welcome to programming” what does str[:3] + [18:] do?

“Welming”

18
New cards

str = “Mickey Mouse” what does len(str) return

12

19
New cards

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

20
New cards

if holler = “red rover, red rover…”what would be the output of print(holler[11:21]

red rover

NOT A LIST!! COMMAS ARE INCLUDED