Python Flashcards
Programs
Lists of instructions the computer preforms in sequential order
Source Code
Program written in a high-level programming language
Python
High-level programming language
Easy
Emphasizes code readability
Python Interpreter
Read instructions from top to bottom, left to rights
Performs instruction validation
run in command line: py or python3
IDE
Integrated Development Environment
Most useful in Python: PyCharm
IDLE
Python’s Integrated Development Learning Environment
String
multiple characters (animals)
Integer
Number without decimal (2)
Float
Decimal number (2.5)
Boolean
True or False
Hashtag #
Renders an entire line as a comment
””” three quotes
Used in the beginning and end of multi-line comments
print()
Prints what is in the ()
Keywords
Python’s reserved words and instructions like print, def
Indentation
Mechanism that associates a block of code with a condition, loop, or class
input function
Used to ask a user for input
Always a string data type
name = input(“Please enter your name: “)
Data Types
String, Integer, Boolean, Float
string formatting
% ex: item 1 = “Hi, my name is %s and I’m %d years old”
.format ex: item2 = “Hi, my name is {} and I’m {} years old”
f ex: item3 = f”Hi, my my name is {} and I’m {} years old”
Logical Operations
Used with Boolean expressions
Truth table: Table that defines the results of a binary operation
AND: Both conditions must be true (to be a true statement or it is false)
Conditional Operations
OR: Only one operation must be true (always true unless both conditions are false)
NOT: Reverse the result of the operation
XOR: Exclusive OR True if the results of the operation aren’t similar (must have a true and false)
Type Casting
Converting one data type to another date type
int(), float(), str()
List
Dynamic data type that can hold different types of data simultaneously.
Starts at 0 [cat, dog, bear] 0=cat
Dictionary
Have a key:value format (ex: personDict = {“name”:”Chad”} )
Dictionaries are identified by curly brackets
Nested Data Structures
Can hold other data structures
nestedDS = [“hello”, {“name”:”John”, “age”:24}, [“one”, “two”]]
This example is a list with a nested dictionary and another list