INSY 3300 Python Final

30 flashcardsby Alejandro
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What does input() always return?
A string
2
Which operator performs floor division in Python?
  • /
  • //
  • %
  • *
3
What sequence does range(2, 10, 3) produce?
2, 5, 8
4
Which logical operator checks that a value is outside a range?
or
5
How many times does the inner body run for an outer range(3) and an inner range(4)?
  • 7
  • 3
  • 12
  • 4
6
What is a void function?
A function that runs its statements and returns no value (None)
7
What happens if you use a local variable from a different function?
A NameError
8
What does file mode 'w' do to existing contents?
Erases them
9
Which part of try/except runs only when no exception occurs?
  • finally
  • except
  • else
  • try
10
What does list.sort() return?
None, because it sorts in place
11
What does b = a do when a is a list?
Makes b point to the same list, not a copy
12
What is [10, 20, 30, 40, 50][1:4]?
  • [10, 20, 30, 40]
  • [20, 30, 40]
  • [20, 30, 40, 50]
  • [10, 20, 30]
13
Are Python strings mutable or immutable?
Immutable
14
What does find() return when the substring is not found?
-1
15
What does 'hello'[
-1] return?
16
What does d.get('c', 0) return if 'c' is not a key?
0
17
How do you create an empty set?
set(), because {} makes an empty dictionary
18
How do set remove() and discard() differ when the item is missing?
remove() raises KeyError; discard() does not
19
What is {1, 2, 3} ^ {3, 4}?
  • {3}
  • {1, 2, 3, 4}
  • {1, 2, 4}
  • {1, 2}
20
Which file mode is used to unpickle with pickle.load?
'rb'
21
What does __init__ do in a class?
Runs automatically when an object is created and initializes its attributes
22
Which parameter must be the first one in every method of a class?
  • cls
  • this
  • self
  • obj
23
What is an accessor method?
A getter that returns an attribute value without changing it
24
What does class Car(Automobile) mean?
Car inherits from Automobile, an "is a" relationship
25
Which SQLite type corresponds to a Python float?
  • REAL
  • INTEGER
  • TEXT
  • BLOB
26
What must a primary key never be?
NULL, and it must be unique
27
What does cur.fetchone() return when no rows remain?
None
28
Which call saves INSERT, UPDATE and DELETE changes?
conn.commit()
29
Which wildcard in a LIKE pattern matches any characters?
  • ?
  • &
  • #
  • %
30
What does CREATE TABLE IF NOT EXISTS prevent?
An error from recreating an existing table on every run
Study all 30 cards for free

More Computer science flashcards

A+ Core 1 Domain 1 Acronyms37 cardsComputer science · Englishatalnagiict32 cardsComputer science · EnglishKidistOS Virtualization25 cardsComputer science · English—Griffith—1.2.3 SOFTWARE DEVELOPMENT20 cardsComputer science · EnglishSabs2023Data Storage and Databases15 cardsComputer science · EnglishAyaanSYO-601 Log files10 cardsComputer science · Englishr3lykSoftware Architecture and Quality Attributes (Wk3)209 cardsComputer science · EnglishSamLinux4 decks · 252 cardsComputer scienceAndrewNetwork Security: OSPF Routing Protocol83 cardsComputer science · EnglishDiandreiDatabases68 cardsComputer science · EnglishXyzboltCS4432 - Database Query Optimization (Week 6 & 7)55 cardsComputer science · Englishaliciadrei microprocessor 146 cardsComputer science · EnglishDiandrei

All Computer science decks

Study these decks in the app

Free on iPhone, Android, Mac and the web. Add any deck to your account in one tap.

Download on the App StoreGet it on Google Play
Study all 30 cards for free