CS 1110 First Test

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

1/54

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.

55 Terms

1
New cards

Sequence

A set of instructions executed in order from top to bottom. An error in one line stops later steps.

2
New cards

Conditional (if)

Executes a block of code only if a specified condition is true.

3
New cards

Repetition (Loop)

Repeats a task a fixed number of times or until a condition is met.

4
New cards

Function (Named Action)

A group of instructions that performs a specific task; defined once and called when needed.

5
New cards

Pseudocode

An informal, language-agnostic description of the steps to solve a problem.

6
New cards

Algorithm

A step-by-step procedure to solve a problem; often described with pseudocode or flowcharts.

7
New cards

Good Algorithm Qualities

Unambiguous, executable, terminating, and correct.

8
New cards

Statement

A single instruction in a program or pseudocode.

9
New cards

Program

A sequence of statements executed to perform a task.

10
New cards

Execute

To run or carry out the instructions in a program.

11
New cards

Keyword

A reserved word in a programming language with a special meaning (e.g., if, else).

12
New cards

Variable

A named storage for a value that can change during execution.

13
New cards

Variable Naming Rules

Names can include letters, numbers, and underscores; cannot start with a number or be a keyword.

14
New cards

Expression

A combination of values, variables, and operators that evaluates to a new value.

15
New cards

Comment

A note in code (prefixed with '#' in Python) that is ignored by the interpreter.

16
New cards

Syntax

The set of rules that defines the structure of valid code in a programming language.

17
New cards

Constant

A variable intended not to change, usually written in all caps (e.g., INCHES_PER_FOOT).

18
New cards

Operators

Symbols for arithmetic and logical operations (e.g., +, -, /, %, //, *).

19
New cards

Floor Division (//)

Division that returns the integer part of the quotient (result may be float if an operand is float).

20
New cards

String Literal

Text enclosed in quotes representing a string.

21
New cards

String Multiplication

Repeats a string a specified number of times (e.g., 'abc' * 3 → 'abcabcabc').

22
New cards

Print()

Outputs one or more values. Commas add spaces automatically between items.

23
New cards

Type()

Returns the data type (class) of a given value.

24
New cards

Input()

Prompts the user for input; the returned value is always a string.

25
New cards

Type Casting

Converting a value from one type to another (e.g., int('7'), float('7.0'), str(7)).

26
New cards

Syntax Error

An error caused by code that violates the programming language's grammar.

27
New cards

Runtime Error

An error that occurs during execution (e.g., division by zero, using an undefined variable).

28
New cards

Logical Error

An error where the program runs without crashing but produces incorrect output.

29
New cards

String Indexing

Accessing individual characters in a string using indices; index 0 is the first, -1 is the last.

30
New cards

String Slicing

Extracting a substring using s[start:end] or s[startstep] (start is inclusive, end is exclusive).

31
New cards

List

A mutable, ordered collection of items defined with square brackets [].

32
New cards

Tuple

An immutable, ordered collection of items defined with parentheses ().

33
New cards

Dictionary

A collection of key-value pairs enclosed in curly braces {}.

34
New cards

Comparison Operators

Operators such as
35
New cards

Boolean

A data type representing True or False.

36
New cards

Boolean Operators

Logical operators (and, or, not) used to combine Boolean expressions.

37
New cards

Truthy/Falsy

Values that evaluate to True or False in Boolean contexts (e.g., 0, '', [], (), None are falsy).

38
New cards

Conditional Statement

Uses if, elif, and else to execute code based on whether conditions are true.

39
New cards

Nested Conditionals

Conditional statements placed inside another conditional block.

40
New cards

Modulus Operator (%)

Returns the remainder of a division operation; useful for checking divisibility.

41
New cards

In Operator

Checks whether an element exists within a collection; returns True or False.

42
New cards

Last Index in Sequence

Always -1, referring to the final element in a sequence.

43
New cards

Slicing Example

"This should be easy"[5:11] yields "should".

44
New cards

Test: Are strings immutable?

Yes. Strings cannot be changed after creation; modifications require creating a new string.

45
New cards

Test: Can you modify a string in place?

No. Assigning a new value to an index (e.g., s[0] = 'H') raises an error.

46
New cards

Test: What is s[1:4] for s = 'hello'?

It returns 'ell' (indexes 1 to 3; end index is exclusive).

47
New cards

Test: How do negative indices work?

They count from the end; s[-1] is the last element, s[-2] is the second-last, etc.

48
New cards

Test: What does s[::2] do?

Returns every second element of the sequence.

49
New cards

Test: What error occurs if you use an undefined variable?

NameError is raised when a variable is used before it is defined.

50
New cards

Test: How do you check if an element is in a list?

Use the 'in' operator (e.g., item in list).

51
New cards

Test: What are common falsy values in Python?

0, '', [], (), {}, and None.

52
New cards

Test: What does the modulus operator (%) return?

It returns the remainder of a division operation.

53
New cards

Test: Can tuples be modified?

No. Tuples are immutable; operations like concatenation create a new tuple.

54
New cards

Test: What is floor division?

Division using // that returns the integer part of the quotient (or float if any operand is a float).

55
New cards

Test: How do you convert a string to an integer?

Use int(), provided the string represents a valid integer.