1/39
Vocabulary flashcards covering data types, input/output, type conversions, and basic functions from Lecture 3.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Type (in programming)
The kind of data stored in a variable that determines how the data is interpreted.
Integer
A whole number that can be positive or negative; has no decimal component.
Floating-Point Number
A real number with a decimal component; represented using mantissa and exponent.
Mantissa
The significant digits of a floating-point number before applying the exponent.
Exponent
The power of ten used to scale a mantissa in a floating-point number.
Boolean
A value that is either True or False used in logical decisions.
String
A sequence of characters used to represent text; defined in quotes.
Quotation marks in strings
Strings can use single or double quotes; the other type can be included via escaping.
Escape character
Backslash used to introduce special characters inside strings.
Triple-quoted string
String enclosed by three consecutive quotes; can span multiple lines and include both quote types.
Backslash escape sequences
Escape sequences introduced by a backslash to represent special characters such as tab, newlines, or quotes.
Forward slash
Symbol used for division in many languages.
Type inference
Python infers a variable's type from how it is created or last assigned.
Explicit typing
Declaring a variable's type directly in languages that require it (not typically needed in Python).
print()
Output values to the console; by default ends with a newline.
input()
Read a line from standard input as a string.
Literal
A fixed value written directly in code (e.g., 3, 'text').
Concatenation
Joining two strings with the plus operator to form a new string.
Addition vs concatenation
Repetition (string)
Multiplying a string by an integer repeats the string.
Converting between types
Changing a value's type using constructors like int(), float(), str(), bool().
int()
Convert a value to integer; decimals are truncated.
float()
Convert a value to floating-point; decimals are preserved.
str()
Convert a value to its string representation.
bool()
Convert a value to boolean; falsey values become False, others True.
Converting from strings to numbers
Strings that clearly represent a number can be converted with int() or float().
int('3')
Converts the string '3' to the integer 3.
float('3.14')
Converts the string '3.14' to the floating-point number 3.14.
repr vs str
repr returns the formal representation used for debugging; str returns a readable, user-friendly form.
print with multiple values
The print function can output several items if given more than one argument; they are separated by spaces by default.
sep and end in print
sep defines the between-item separator; end defines what is printed at the end.
f-strings
Formatted string literals that embed expressions inside braces after prefix f.
Format specifier in f-strings
Inside placeholders, after colon you can specify format like .4f to control precision.
Alignment in f-strings
Input prompt
The string passed to input is printed as a prompt before reading input; no automatic newline after the prompt.
from math import *
Import statement to bring all names from the math module into the namespace (e.g., pi).
def function
The keyword to define a function; followed by name, parameters, colon, and indentation for the body.
Parameters vs Arguments
Parameters are the names in a function definition; arguments are the values supplied when calling.
Return value
The value produced by a function via the return statement.
Indentation
Python uses indentation to define code blocks; typically 4 spaces.