CS 1315 Final

0.0(0)
Studied by 2 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:08 PM on 7/21/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

64 Terms

1
New cards

syntax error

The program does not run, caught by the interpreter

2
New cards

runtime error

The program runs, but produces an error, caught by the interpreter

3
New cards

semantic error

The program runs, and does not produce an error, caught by the programmer. The program produces unexpected output

4
New cards

type conversion - int()

int, float, numeric str, True = 1, False = 0. Ex: can not convert int(“three”).

5
New cards

type conversion - float()

int, float, numeric str, True = 1.0, False = 0.0. Ex: can not convert float(“three”).

6
New cards

type conversion - str()

int, float, numeric str, str, True = “True”, False = “False”

7
New cards

type conversion - bool()

all data types = True except bool(False) and bool(0)

8
New cards

*

multiplication

9
New cards

/

division

10
New cards

//

floor division, a whole number

11
New cards

bigger number % smaller number

modulus, gives remainder after floor division

12
New cards

smaller number % bigger number

result is the smaller number

13
New cards

Order of Precedence

PEMDAS + R + L

14
New cards

print()

displays a value on the screen

15
New cards

input()

gets input from the user to assign to a variable

16
New cards

immutable

once created, object cannot be changed. If it is repeated, a new variable is assigned. EX: str

17
New cards

Operator: *

makes copies of operand. multiplication of numeric literals. repetition of a str literal by an integer

18
New cards

Operator: +

addition of numeric literals, concatenation of str literals

19
New cards

Operators: not (!), and (&), or (|)

  • True and True is True, all others are False

  • False or False is False, all others are True

  • not False is True

  • not True is False

20
New cards

\n

new line

21
New cards

\t

tab

22
New cards

\\

back slash

23
New cards

\’

single quote

24
New cards

\”

double quote

25
New cards

len()

The number of characters in a string is called the length of the string. Empty string (“ ”) has len() of 0. Each character in a string has an index value; 0 through len()-1

26
New cards

index[0]

first char

27
New cards

index[–1] or [len()-1]

last char

28
New cards

Operator: []

returns a char at a given string index, spaces count as chars

29
New cards

f-string

formatted string literal. Use {} to refer to variables. Ex: print(f “{name} your total is ${total:.2f}.”) → Bob your total is $5.40.

30
New cards

slicing [X:X:X]

  • [start:stop:step] spaces count as chars so include them in the steps

  • steps do not depend on index number, just number of chars

  • Default start is index[0], default stop is index[-1], default step is 1

  • last char is not included

31
New cards

string methods no arguments

32
New cards

string methods with arguments

33
New cards

Operator: in

tests for membership

34
New cards

while loop

condition-controlled

35
New cards

for loop

count-controlled

36
New cards

lists

  • defined by []

  • indexable

  • mutable

37
New cards

list.remove(value)

Removes the first occurrence of a specified value

38
New cards

list.insert(index,value)

Adds an element at the specified index position

39
New cards

list.append(value)

sed to add items to a list – item is appended to the end of the existing list

40
New cards

del list[index]

removes an element from a list - can be used to delete a single index of a list, a slice of a list, or the complete list

41
New cards

list.insert(index,value)

inserts an element at the specified position

42
New cards

separator.join(iterable)

returns all items in an iterable and joins them into one string.

43
New cards

string.strip()

removes any set of characters that are leading or trailing a string

44
New cards

string.split()


returns a list of sub-strings from the string

45
New cards

break

used to break out of a for loop or a while loop

46
New cards

tuple

  • a comma-separated sequence of values enclosed in parentheses.

  • immutable

  • EX: oneTup = (5,)

  • can use + and * to add to tuple or multiply

47
New cards

packing

refers to tuples

48
New cards

unpacking

refers to tuples

49
New cards

tuple.index(value)

searches for a specified value and returns the first position if found

50
New cards

open txt: Reading mode

  • retrieving data from an input file

  • file_objectname = open(filename, 'r')

51
New cards

open txt: Writing mode

  • saving data to an output file

  • file_objectname = open(filename, 'w')

52
New cards

open txt: Appending mode

  • adding data to an existing file, will create a file if the specified file does not exist

  • file_objectname = open(filename, 'a')

53
New cards

open txt: Creating mode

  • will create a file, returns an error if the file exist

  • file_objectname = open(filename, 'x')

54
New cards

.read()

read all characters as a single str

used to read entire file contents as a str.

55
New cards

.readline()

returns one line from the file

used to read a line from the file as a str

56
New cards

.readlines()

Returns a list of strings, each representing a single line of the file

used to read each line as a str into a list.

57
New cards

.write()

used to write data to a file, will overwrite any existing data, and does not include a newline character

58
New cards

.close()

always close your files, as all changes are not written until after close.

59
New cards

txt files

A plain text file containing unformatted text

60
New cards

csv files

A comma-separated values file used for storing tabular data
•Each line represents a data record.
•Fields within the record are separated by commas.

61
New cards

csv.reader()

Reads rows from a CSV file

Converts each row into a list of strings

62
New cards

csv.writer()

writes rows to a CSV file

Writes iterable data (e.g., list/tuple) to a CSV file

63
New cards

{}

indicates a dictionary

64
New cards

how to index into a dictionary

use the key