Chapter 2 - Input, Processing, & Input

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

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:36 PM on 6/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

56 Terms

1
New cards

print ()

displays text

2
New cards

Why must the text in the print() function be enclosed in quotes?

so the interpreter identifies it as a string

3
New cards

string

sequence of characters; can include letters, numbers and symbols

4
New cards

True or false: arithmetic expressions can be performed within a print() command

true

5
New cards

True or false: arithmetic expressions inside the print() function must be enclosed in quotes

false

6
New cards

comments

short notes placed in different parts of the program, explaining how those parts of the program work; started by the # symbol and ignored by the interpreter

7
New cards

guidelines for comments

  • should be clear and concise

  • don’t comment on things that are self-explanatory

  • update comments as the code evolves

  • use comments to explain logic

8
New cards

variable

a container for storing data values (e.g. strings or numbers)

  • created and assigned using “=”

  • can consist of alphabets, digits, and underscores

  • cannot have special symbols and cannot begin with a number

9
New cards

camelCase

the variable name begins with lowercase letters, and the first character of the second and subsequent words is written in uppercase

10
New cards

snake_case

underscores replace spaces in separating words in variable names

11
New cards

How can you display multiple items with one print statement?

by separating the items with commas

12
New cards

data types

categories of values in memory

13
New cards

int

value written as a whole number without a decimal point

14
New cards

float

value written with a decimal point

15
New cards

str

sequence of characters

16
New cards

input()

used to read a line of input from the user; usually displays a prompt message to guide the user on what information to provide

17
New cards

What data type does the input() function always return?

string

18
New cards

What built-in functions can be used to convert between data types?

  • int(item) - converts to integer

  • float(item) - converts to float

19
New cards

What does the item have to be for type conversion to work?

a valid numeric value

20
New cards

%

remainder

21
New cards

**

exponent

22
New cards

True or false: the Python interpreter followers order of operations

true

23
New cards

How can you break a statement into multiple lines?

using backslash (\)

24
New cards

hard-coding

storing values in variables that are not dependent on user input

  • makes the code hard to change

  • good for learning but not for applications

25
New cards

multiple assignment

assigning values to multiple variables in a single statement

26
New cards

What does combining different data types in a print statement require?

converting one type to another

27
New cards

f-string (formatted string literal)

allows you to embed expressions directly inside strings

  • gives a more flexible and readable output format that using the str() function

28
New cards

f-string format

print("‘{<index>:<padding character><alignment character><block size><precision>}’)

29
New cards

What does it mean for a string to be immutable?

it cannot be changed after creation

30
New cards

string concatenation

combining strings using the + operation

  • ex: greeting = “Hello” + “ “ + “World”

31
New cards

escape sequence

a sequence of characters that when used inside a character or string, is converted into another character or series of characters that may be difficult or impossible to express directly

32
New cards

\’

single quote

33
New cards

\\’

double quote

34
New cards

\\

backslash

35
New cards

\n

newline

36
New cards

\r

carriage return

37
New cards

\t

horizontal tab

38
New cards

\b

backspace

39
New cards

\v

vertical tab

40
New cards

\0

null character

41
New cards

index

position of a character inside a string

42
New cards

What does indexing start at for the first character?

0

43
New cards

What symbol do you use to access a character at a specific index?

square brackets [ ]

44
New cards

negative indexing

accessing characters from the back end of the string

45
New cards

string slicing

allows you to obtain a substring by specifying a range of indices

46
New cards

string slicing format

string [start:stop]

  • start is inclusive

  • stop is exclusive

47
New cards

str.lower()

converts all characters to lowercase

48
New cards

str.upper()

converts characters to uppercase

49
New cards

str.strip()

removes leading and trailing whitespace

50
New cards

str.split()

splits the string into a list of substrings

51
New cards

str.join(iterable)

joins elements of an iterable to a single string

52
New cards

str.replace(old, new)

replaces occurrences of a substring

53
New cards

str.find(sub)

returns the lowest index of the substring

54
New cards

str.startswith(prefix)

checks if the string starts with a prefix

55
New cards

str.endswith(suffix)

checks if the string ends with a suffix

56
New cards

len(obj)

returns the length of an object