programming for the humanities

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

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:10 AM on 9/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

45 Terms

1
New cards

Multiline string

A single string that contains several lines of text, usually created with triple quotation marks.

2
New cards

What are the two types of cells in Google Colab?

.Code cells contain executable Python code. Text cells contain explanations and documentation.

3
New cards

How do you execute a code cell without clicking the play button?

Press Ctrl + Enter.

4
New cards

What punctuation must follow print in Python

Parentheses: print()

5
New cards

What is the difference between these?

Python

print(23 + 5)

print("23 + 5")

The first displays 28 because Python evaluates it. The second displays 23 + 5 because quotation marks make it literal text.

6
New cards

What is a variable?

A name representing a place in memory where a value is stored.

7
New cards

What symbol assigns a value to a variable?

The equal sign, =.

8
New cards

: What is the difference between these?

print(my_variable)

print("my_variable")

The first displays the variable’s value. The second displays the literal text my_variable.

9
New cards

What is a string?

A piece of text placed inside quotation marks.

10
New cards

What is an integer?

A whole number without a decimal point.

11
New cards

What is a float?

A number with a decimal point, such as 30.5.

12
New cards

What is an f-string?

A formatted string that combines text with variables, numbers, or calculations.

13
New cards

How do you create an f-string?

Put f before the opening quotation mark and put variables inside curly braces { }.

Python

1

print(f"The year is {year}.")

14
New cards

Given item = "book" and price = 20, write a line that displays ā€œThe price of the book is 20.ā€

print(f"The price of the {item} is {price}.")

15
New cards

What data type does input() always return?

A string, even when the user enters a number.

16
New cards

What is typecasting?

Converting a value from one data type to

17
New cards

Which functions convert input into numbers?

int() converts to a whole number. float() converts to a decimal number.

18
New cards

What does NameError mean?

A variable is undefined, misspelled, incorrectly capitalized, or has not been recreated after the runtime restarted.

19
New cards

What happens here?print(hello)

Python treats hello as a variable. If it has not been defined, it produces a NameError.

20
New cards

What does TypeError mean?

An operation uses incompatible data types, such as adding an integer to a string.

21
New cards

Why does this cause a TypeError?

Python

1

year = 1813

2

print("The year is " + year)

"The year is " is a string, but year is an integer. Direct concatenation requires two strings.

22
New cards

What does ValueError mean?

Python cannot convert a value into the requested type, such as converting "hello" with int().

23
New cards

Why does int("1.5") produce a ValueError?

1.5 is a decimal value, not a valid whole-number string. Use float() instead.

24
New cards

What are the three important errors to distinguish?

  • NameError: undefined or misspelled variable

  • TypeError: incompatible data types

  • ValueError: unsuitable value for conversion


25
New cards

What does the input() function do?

It pauses the program, waits for the user to type something, and returns the answer as a string.

26
New cards

What is a prompt?

A message inside input() telling the user what to enter.

Python

1

input("Please enter your age: ")

27
New cards

If the user enters 5 and 10 without typecasting, what does number_one + number_two produce?

510, because the two input strings are concatenated.

28
New cards

Why does the following code produce an error?

Python

1

number_one = int(input("Enter a number: "))

2

number_two = input("Enter another number: ")

3

print(number_one + number_two)

number_one is an integer, but number_two is a string. Adding them causes a TypeError.

29
New cards

How do you correctly receive a whole number?

number = int(input("Enter a number: "))

30
New cards

How do you correctly receive a decimal number?

number = float(input("Enter a number: "))

31
New cards

What is the difference between immediate and later typecasting?

Immediate typecasting converts input when it is entered. Later typecasting preserves the original string and converts it only when needed.

32
New cards

Why might you preserve "001" as a string?

Converting it to an integer changes it to 1 and removes the leading zeros. This matters for student IDs and reference numbers.

33
New cards

How do you separate multiple items inside print()?

Use commas.

Python

1

print("Total:", 20)

34
New cards

What does Python automatically add between comma-separated items?

One space.

35
New cards

How do you remove the automatic space?

Use sep="".

Python

1

print("Total: ", 20, sep="")

36
New cards

What is string concatenation?

Joining strings using +.

37
New cards

What happens when a string is multiplied by an integer?

The string is repeated.

Python

1

"-" * 5

38
New cards

What do these special characters do?

  • \n: new line

  • \t: tab position

  • \\: print a backslash


39
New cards

Why does the first code execution take longer?

Google must start and connect a temporary Python runtime.

40
New cards

Can a variable created in one code cell be used in another?

Yes, if the first cell was executed and the same runtime remains active.

41
New cards

What happens to variables when Colab terminates the runtime?

Their values disappear from memory, but the notebook and code remain saved.

42
New cards

How can you fix a NameError caused by a restarted runtime?

Select Run all to execute the cells from the beginning and recreate the variables.

43
New cards

What is literate programming?

Combining human-readable explanations with executable code in one document.

44
New cards

How does Colab support literate programming?

Text cells explain and document the program, while code cells contain executable instructions.

45
New cards

What is the main difference between Colab’s free and paid versions?

The paid version offers more resources and longer runtimes. The free version is sufficient for this course.