Computer Programming - Semester 2 Final

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

1/43

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.

44 Terms

1
New cards

\ n

New line character

2
New cards

\ t

Tab character

3
New cards

Boolean

A value that is either true or false

4
New cards

Character

A single character

5
New cards

Comments

Describes what the program does and how you understand it

6
New cards

Concatenation

Combining two strings together

7
New cards

Counter

A variable that counts during a loop

8
New cards

Decrement

Decreases the value of a variable

9
New cards

Dictionary

A list containing a key and a value

10
New cards

Hard drive

Where everything is stored

11
New cards

IDE

Integrated Development Environment, where software is developed and run

12
New cards

In

A keyword used to check membership in a sequence

13
New cards

Increment

Increases the value of a variable

14
New cards

Index

The position within a string, list, set, or tuple

15
New cards

Infinite loop

A loop that runs endlessly until stopped by the user

16
New cards

Integer

A whole number

17
New cards

Key words

Reserved words used as commands in the language

18
New cards

Key Values

Assigning a value to a key in a dictionary

19
New cards

Len()

Finds the length of a collection

20
New cards

List

A variable that holds multiple values

21
New cards

Logical Operators

Operators like And, Or, and Not

22
New cards

RAM

Random Access Memory, short-term storage used while a program runs

23
New cards

Relational Operators

Operators like <, >, <=, >=, ==

24
New cards

String

A sequence of characters (word or phrase)

25
New cards

Tuple

A collection that cannot be changed after creation

26
New cards

Math Operators

Operators like +, -, /, *, **, and %

27
New cards

Float

A variable that can store decimal numbers

28
New cards

Rules for variable assignment

Use camelCase, avoid reserved keywords, no spaces, and don’t start with a number

29
New cards

Difference between list and tuple (1)

A list is defined with square brackets [], while a tuple is defined with parentheses ()

30
New cards

Difference between list and tuple (2)

Tuples can hold all types of data, whereas lists can hold only one type of data. Tuples are immutable (cannot be modified), but lists are mutable.

31
New cards

readline()

Reads a single line from a file

32
New cards

Random.randint() vs Random.randrange()

Random.randint() includes the stop value, while Random.randrange() does not

33
New cards

While loop vs For loop

A for loop iterates a specific number of times and automatically increments, while a while loop repeats until a condition is met, often using a sentinel

34
New cards

Assignment operators (+=, -=)

Modify the variable’s value by performing an operation and reassigning it to itself

35
New cards

Four parts of every loop

Counter, sentinel, comparison statement, and increment/check for new input

36
New cards

Colon in Python

Indicates that the following code block is part of a function or control structure

37
New cards

Global Scope

Variables declared outside functions, accessible throughout the program

38
New cards

Local Scope

Variables declared inside a function, accessible only within that function

39
New cards

Block Scope

A variable that exists only inside a specific block of code like a loop

40
New cards

Sending parameters to a function

Place variables inside the function’s parentheses

41
New cards

Returning a value from a function

Use the return statement, followed by the value to return, and assign it to a variable

42
New cards

Why should you comment your code?

Comments help explain what the code does, both for yourself and others who read it

43
New cards

Ways to access a text file

Append (modify content), Read (retrieve content), Write (create or overwrite content)

44
New cards

What do you do when you're finished with a file?

Close the file to prevent data corruption