CS 1110 First Test

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 54

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

55 Terms

1

Sequence

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

New cards
2

Conditional (if)

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

New cards
3

Repetition (Loop)

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

New cards
4

Function (Named Action)

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

New cards
5

Pseudocode

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

New cards
6

Algorithm

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

New cards
7

Good Algorithm Qualities

Unambiguous, executable, terminating, and correct.

New cards
8

Statement

A single instruction in a program or pseudocode.

New cards
9

Program

A sequence of statements executed to perform a task.

New cards
10

Execute

To run or carry out the instructions in a program.

New cards
11

Keyword

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

New cards
12

Variable

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

New cards
13

Variable Naming Rules

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

New cards
14

Expression

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

New cards
15

Comment

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

New cards
16

Syntax

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

New cards
17

Constant

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

New cards
18

Operators

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

New cards
19

Floor Division (//)

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

New cards
20

String Literal

Text enclosed in quotes representing a string.

New cards
21

String Multiplication

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

New cards
22

Print()

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

New cards
23

Type()

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

New cards
24

Input()

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

New cards
25

Type Casting

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

New cards
26

Syntax Error

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

New cards
27

Runtime Error

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

New cards
28

Logical Error

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

New cards
29

String Indexing

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

New cards
30

String Slicing

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

New cards
31

List

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

New cards
32

Tuple

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

New cards
33

Dictionary

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

New cards
34

Comparison Operators

Operators such as
New cards
35

Boolean

A data type representing True or False.

New cards
36

Boolean Operators

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

New cards
37

Truthy/Falsy

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

New cards
38

Conditional Statement

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

New cards
39

Nested Conditionals

Conditional statements placed inside another conditional block.

New cards
40

Modulus Operator (%)

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

New cards
41

In Operator

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

New cards
42

Last Index in Sequence

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

New cards
43

Slicing Example

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

New cards
44

Test: Are strings immutable?

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

New cards
45

Test: Can you modify a string in place?

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

New cards
46

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

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

New cards
47

Test: How do negative indices work?

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

New cards
48

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

Returns every second element of the sequence.

New cards
49

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

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

New cards
50

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

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

New cards
51

Test: What are common falsy values in Python?

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

New cards
52

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

It returns the remainder of a division operation.

New cards
53

Test: Can tuples be modified?

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

New cards
54

Test: What is floor division?

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

New cards
55

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

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

New cards

Explore top notes

note Note
studied byStudied by 18 people
762 days ago
5.0(1)
note Note
studied byStudied by 2 people
34 days ago
5.0(1)
note Note
studied byStudied by 17 people
837 days ago
5.0(1)
note Note
studied byStudied by 11 people
641 days ago
5.0(2)
note Note
studied byStudied by 22 people
882 days ago
4.5(2)
note Note
studied byStudied by 15 people
848 days ago
5.0(2)
note Note
studied byStudied by 22 people
162 days ago
5.0(2)
note Note
studied byStudied by 10445 people
681 days ago
4.6(34)

Explore top flashcards

flashcards Flashcard (514)
studied byStudied by 2 people
651 days ago
5.0(1)
flashcards Flashcard (59)
studied byStudied by 7 people
516 days ago
5.0(1)
flashcards Flashcard (181)
studied byStudied by 2 people
101 days ago
5.0(3)
flashcards Flashcard (25)
studied byStudied by 5 people
728 days ago
5.0(1)
flashcards Flashcard (32)
studied byStudied by 13 people
775 days ago
4.0(1)
flashcards Flashcard (188)
studied byStudied by 2 people
638 days ago
5.0(1)
flashcards Flashcard (27)
studied byStudied by 29 people
541 days ago
5.0(2)
flashcards Flashcard (464)
studied byStudied by 36812 people
688 days ago
4.1(403)
robot