Python Fundamentals and Algorithms Explained
Classified in Computers
Written on in
English with a size of 5.17 KB
Algorithms
Algorithms involve inputs, instructions, outputs, and a purpose.
Instruction Types
- Instruction
- Decision
- Loop
- Variable
- Function
Python Basics
Comments
Comments explain what code is for, intended for human readers.
Variables
Storing a value in a variable is called assignment. It's best practice not to use generic names.
Calculations (Operators)
+: Addition-: Subtraction*: Multiplication/: Division//: Integer Division (e.g.,6 // 4 = 1)%: Remainder / Modulo (e.g.,6 % 4 = 2)**: Exponentiation
mass_in_kg = 15
weight_in_pounds = mass_in_kg * 2.2
print('the weight in pounds is: ', weight_in_pounds)
user_name = input("enter your user name: ")
print('hello', user_name)
Data Types
- int: Integer numbers (e.g., -1, 0, 2, 1000)
- float: Floating-point (real)