Python programming
shebang
Strings
Print a string
#!/bin/python3
print("Hello world!") # double quotes
print('Hello world!') # single quotes
print("""This string runs
multiple lines""") # triple quotes for multiple lines
print("This string is "+"awesome") # concatenationUsing f-Strings
# Will print The temperature 75F in degrees celsius is 23.88888888888889C
print(f"The temperature 75F in degrees celsius is {(75 - 32) * 5 / 9}C")
# It works also with multiligne strings
print(f"""
Most countries use the metric system for recipe measurement,
but American bakers use a different system. For example, they use
fluid ounces to measure liquids instead of milliliters (ml).
So you need to convert recipe units to your local measuring system!
For example, 8 fluid ounces of milk is {8 * 29.5735} ml.
And 100ml of water is {100 / 29.5735} fluid ounces.
""")
# This will print
'''
Most countries use the metric system for recipe measurement,
but American bakers use a different system. For example, they use
fluid ounces to measure liquids instead of milliliters (ml).
So you need to convert recipe units to your local measuring system!
For example, 8 fluid ounces of milk is 236.588 ml.
And 100ml of water is 3.381405650328842 fluid ounces.
'''
# It also works on variables
my_name = "gabrielle"
print(f"Hello {my_name}!")
# this will print Hello gabrielle!
# And we can mix var and computation as follow
fav_num = 8
print(f"Your favorite number plus 10 is {fav_num+10}")
# this will print Your favorite number plus 10 is 18type()
Math
Variables and Methods
Functions
Boolean Expressions
Relational and Boolean operators
Conditional Statements
Lists (mutable)
Tuples (immutable)
Looping
For loops
While loops
Importing modules
Advanced strings
Dictionaries
Sys
Reading and writing files
Sockets
Building a port scanner
Virtual Environments
Using functions from a local file
Built-in packages
The math package
The statistics package
The random package
The pandas package
Package matplotlib
Package Beautiful soup
Use APIs
Example with a weather API
Resources
Last updated



