Real cs 5-9 true false

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/52

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.

53 Terms

1
New cards

The break statement can be used to exit a loop prematurely

True

2
New cards

It is possible to use the break statement to exit multiple nested loops at once

False

3
New cards

The continue statement skips the rest of the current iteration and moves to the next

True

4
New cards

The sequence from range(n) starts at 1 and goes up to (but not including) n

False

5
New cards

Nested loops require using both for and while loops

False

6
New cards

Infinite loops occur when the loop condition never becomes false or there is no exit statement in the body

True

7
New cards

The body of a while loop is guaranteed to execute at least once

False

8
New cards

A while True loop runs indefinitely until a break or an error occurs

True

9
New cards

The loop condition in a while loop is evaluated before each iteration

True

10
New cards

The loop control variable in for x in range(2) can be accessed outside the loop

True

11
New cards

A function must always have a return statement

False

12
New cards

A variable defined within a function is limited to that function and not accessible outside it

True

13
New cards

You can call a function without passing arguments even if it has parameters with no default value

False

14
New cards

If a function lacks a return statement (or returns without a value) it implicitly returns 0

False

15
New cards

A function can have multiple parameters with the same name as long as they have different default values

False

16
New cards

Keyword arguments are passed by position and positional arguments are specified by name

False

17
New cards

Passing a mutable object to a function allows the function to modify that object

True

18
New cards

break and return are interchangeable

False

19
New cards

A function may have multiple return statements but only one executes per call

True

20
New cards

Functions can return multiple values with a comma-separated return (tuple packing)

True

21
New cards

Python allows creating a class with no attributes or methods

True

22
New cards

Variables defined in init need the self prefix to become instance attributes

True

23
New cards

All user-defined classes in Python are mutable

False

24
New cards

If a class lacks str — you can still print an object of that class

True

25
New cards

You can instantiate a user-defined class without explicitly defining init

True

26
New cards

All attributes of a class can be accessed and modified from outside the class

False

27
New cards

Modifying an attribute of one instance affects that attribute in all other instances

False

28
New cards

When creating a class object you must explicitly provide values for all instance attributes

False

29
New cards

In method definitions — self refers to the instance and lets the method access its attributes

True

30
New cards

You can change an object’s class after it is created

False

31
New cards

If init defines attributes — all instances of the class will have those attributes

True

32
New cards

Characters are a different type from strings in Python

False

33
New cards

If s1 == s2 then s1 in s2 returns False because in checks partial matches

False

34
New cards

You can directly modify a character in a string with s[2] = 'z'

False

35
New cards

To loop over indices of s you can use for i in range(len(s) + 1)

False

36
New cards

Strings are 0-based indexed

True

37
New cards

strip() removes both leading and trailing whitespace

True

38
New cards

Relational operators compare strings by length

False

39
New cards

Strings can be indexed using negative numbers

True

40
New cards

For a string s — min(s) == max(s) is always False

False

41
New cards

islower() · isdigit() · isalpha() are standalone functions (not methods)

False

42
New cards

In for i in s — i refers to a character of s each iteration

True

43
New cards

Comparing two lists of different lengths causes an error

False

44
New cards

It is possible to directly convert a list to a string in Python

True

45
New cards

append() adds an element to the beginning of a list

False

46
New cards

[x for x in range(10) if not x % 2] creates a list of only positive even integers

False

47
New cards

Lists cannot be negatively indexed

False

48
New cards

remove() deletes an element by index

False

49
New cards

You can convert items of other (iterable) types directly to a list

True

50
New cards

Lists can only contain items of the same data type

False

51
New cards

The += operator can concatenate two lists

True

52
New cards

Lists have a fixed maximum size after which you cannot add elements

False

53
New cards

pop() removes and returns the last element of a list (by default)

True