Quiz 1 Flashcards
computer program
consists of instructions: input, process, and output
python
- conceived in late 80s by guido van rossum
- named after british comedy group “monty python”
- most popular = python 3.x
python interpreter
computer program that executes code written in the python programming language
IDE
programmming development is usually done with an integrated development environment (IDE) (vs code = our ide)
basic output
function print = string literal - letters/numbers/spaces/symbols (* or #) surrounded by pair of matching single or double quotes
basic output - variables
comma is used to ouput multiple items in one statement (separates multiple items)
basic output - variables
comma is used to ouput multiple items in one statement (separates multiple items)
errors
SyntaxError - violating programming language’s rules
TypeError - operation uses incorrect types
NameError - uses variale that does not exist
ValueError - invalid value is used (giving letters to int())
parts of a program
- library imports
- functions
- expressions
- statements
- variables
parts of a program
- library imports
- functions
- expressions
- statements
- variables
library imports
things other people have written (or you wrote outside of the script
statement / expression
program instruction that tells python to do something / evaluates and returns a value
function
block of reusable code you write yourself
tokens
keywords: def, import, if else
operators: – + - * / // % =
delimiters: () [] {} , ; : #
literals: 123 7.6 true
whitespace
- ignored in expressions and statements
- beginning of line = indentation
- python uses indenation/whitespace for syntax
- cannot appear in middle of an operator
assignment statement
assigns a variable with a value using the operator =
variable naming conventions
- start with a letter [pay attention to case sensitivity]
- dont start with a number, dont use a keyword
data types
umbers, booleans, strings, and containers (lists, dictionaries, sets)
numbers
int() = whole/counting numbers, positive/negatives (includes 0)
float() = numbers with decimal points
booleans (bool)
true or false, often used to make decisions based on conditions
strings
str() = sequence of characters which include letters, nmbers, symbols, spaces [whitespaces]
- enclosed by single/double quotes
container
collection of data types - can contain data of more than one data type
- lists
- dictionaires
- sets
lists
- collection of items
- can have diff data types inside
- enclosed by square brackets [ ]
- items are separated by commas ,
dictionary
- dict = collection of key-value pairs
- keys and values can be data of any type
- enclosed by braces { }
- key : valu - separated by a colon