Lecture 3: Data Types, Input/Output, and Basic Functions

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

1/39

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering data types, input/output, type conversions, and basic functions from Lecture 3.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

Type (in programming)

The kind of data stored in a variable that determines how the data is interpreted.

2
New cards

Integer

A whole number that can be positive or negative; has no decimal component.

3
New cards

Floating-Point Number

A real number with a decimal component; represented using mantissa and exponent.

4
New cards

Mantissa

The significant digits of a floating-point number before applying the exponent.

5
New cards

Exponent

The power of ten used to scale a mantissa in a floating-point number.

6
New cards

Boolean

A value that is either True or False used in logical decisions.

7
New cards

String

A sequence of characters used to represent text; defined in quotes.

8
New cards

Quotation marks in strings

Strings can use single or double quotes; the other type can be included via escaping.

9
New cards

Escape character

Backslash used to introduce special characters inside strings.

10
New cards

Triple-quoted string

String enclosed by three consecutive quotes; can span multiple lines and include both quote types.

11
New cards

Backslash escape sequences

Escape sequences introduced by a backslash to represent special characters such as tab, newlines, or quotes.

12
New cards

Forward slash

Symbol used for division in many languages.

13
New cards

Type inference

Python infers a variable's type from how it is created or last assigned.

14
New cards

Explicit typing

Declaring a variable's type directly in languages that require it (not typically needed in Python).

15
New cards

print()

Output values to the console; by default ends with a newline.

16
New cards

input()

Read a line from standard input as a string.

17
New cards

Literal

A fixed value written directly in code (e.g., 3, 'text').

18
New cards

Concatenation

Joining two strings with the plus operator to form a new string.

19
New cards

Addition vs concatenation

  • adds numbers; for strings, + concatenates.
20
New cards

Repetition (string)

Multiplying a string by an integer repeats the string.

21
New cards

Converting between types

Changing a value's type using constructors like int(), float(), str(), bool().

22
New cards

int()

Convert a value to integer; decimals are truncated.

23
New cards

float()

Convert a value to floating-point; decimals are preserved.

24
New cards

str()

Convert a value to its string representation.

25
New cards

bool()

Convert a value to boolean; falsey values become False, others True.

26
New cards

Converting from strings to numbers

Strings that clearly represent a number can be converted with int() or float().

27
New cards

int('3')

Converts the string '3' to the integer 3.

28
New cards

float('3.14')

Converts the string '3.14' to the floating-point number 3.14.

29
New cards

repr vs str

repr returns the formal representation used for debugging; str returns a readable, user-friendly form.

30
New cards

print with multiple values

The print function can output several items if given more than one argument; they are separated by spaces by default.

31
New cards

sep and end in print

sep defines the between-item separator; end defines what is printed at the end.

32
New cards

f-strings

Formatted string literals that embed expressions inside braces after prefix f.

33
New cards

Format specifier in f-strings

Inside placeholders, after colon you can specify format like .4f to control precision.

34
New cards

Alignment in f-strings

35
New cards

Input prompt

The string passed to input is printed as a prompt before reading input; no automatic newline after the prompt.

36
New cards

from math import *

Import statement to bring all names from the math module into the namespace (e.g., pi).

37
New cards

def function

The keyword to define a function; followed by name, parameters, colon, and indentation for the body.

38
New cards

Parameters vs Arguments

Parameters are the names in a function definition; arguments are the values supplied when calling.

39
New cards

Return value

The value produced by a function via the return statement.

40
New cards

Indentation

Python uses indentation to define code blocks; typically 4 spaces.