Image for post
Image for post
Photo by Brooke Lark on Unsplash

How should you style your code?

The Zen of Python, by Tim PetersBeautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should…


Image for post
Image for post
Photo by Joshua Hoehne on Unsplash

What is a Dictionary?


Image for post
Image for post
Image by congerdesign from Pixabay

Slicing a List

names = ["michael", "dwight", "jim", "kevin", "andy"]
print(names[0:2])
>>> ['michael', 'dwight']


Image for post
Image for post
Image by Arek Socha from Pixabay

What is an If Statement?

name = "jill"if name == "jill":
print("Hey Jill")
elif name == "john":
print("Hello John")
else:
print("Wait a minute, who are you?")
>>> Hey Jill
for number in range(1, 101):
if number == 7:
print(str(number) + " is my favorite number!")
elif number == 50:
print(str(number) + " is half of 100!") …


Image for post
Image for post
Image by Jose Antonio Alba from Pixabay

Tuples

names = ("frank", "john")
print(names[0])
print(names[1])
>>> frank>>> john
names = ("frank", "john")
print(names[0])
print(names[1])
names[0] = "will">>> frank>>> johnTraceback (most recent call last): File "main.py"…


Image for post
Image for post
Photo by Andrew Buchanan on Unsplash

Using the range() Function

for i in range(0, 3):
print(i)
>>> 0>>> 1>>> 2


Image for post
Image for post
Photo by Tine Ivanič on Unsplash

Looping through a List

friends = ["kyle", "paul", "chris"]
print(friends[0])
print(friends[1])
print(friends[2])
>>> kyle>>> paul>>> chris
friends…


Image for post
Image for post
Photo by Alicia Slough on Unsplash

What is a List?


Image for post
Image for post
Photo by Emily Morter on Unsplash

Strings

double_quotes = "This is a string with double quotes."
single_quotes = 'This is a string with single quotes.'
print(double_quotes)
print(single_quotes)
>>> This is a string with double quotes.>>> This is a string with single quotes.
as_quote = 'And…


Image for post
Image for post
Photo by David Clode on Unsplash

Variables

print("Hello World")>>> Hello World
message = "Hello World"
print(message)
>>> Hello World
message = "Hello World"
print(message)
message = "Hello Python"
print(message)
>>> Hello World>>> Hello Python

Aldrin Caalim

Learning is neat.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store