Python
Python is a general-purpose programming language known for readable syntax. It's a common first language because you can get useful programs running quickly without much ceremony.
Variables and types
A variable is a name that points at a value. Python figures out the type for you.
name = "Ada"
age = 36
height = 1.70
is_student = False
Conditions and loops
Use if to make decisions and for/while to repeat work.
for i in range(3):
if i % 2 == 0:
print(i, "is even")
else:
print(i, "is odd")
Functions
A function groups code you want to reuse. It takes inputs (arguments) and can return a value.
def greet(name):
return "Hello, " + name
print(greet("world"))
Lists and files
Lists hold ordered collections. Reading a file is a few lines:
lines = open("notes.txt").read().splitlines()
for line in lines:
print(line)