24
Python basic cheat sheets!
hi guys I will give you a cheat sheet for python >:)
1> what is python?
python is an OOP(Object-Oriented-programming) language created by Guido Van Rossum, made in February 20, 1991.
2> info about Guido Van
Guido used to work in Google, he also helped create DropBox
3> basic functions
3.1> Hello World!
#this is a comment
#all you have to do for printing hello world is this:
print("Hello World!")
3.2> Variables!
x = "this is a variable!"
#to print the variable do this:
print(x)
also you can add the variables!
a = 2
b = 3
#if you want you can do print(a+b)
#but to make it more comfortable you can do this:
print("2 + 3 is " a+b"!")
3.3> inputs!
input("hi! ")
print("bye")
3.4> if
x = "hi!"
if x == "bye!": #the == is important!
print()
3.5 (PROJECT) lets make a chatbot!
name = input("hello! what is your name? ")
print("nice to meet you "name)
color = input("so, what is your favor of color? ")
if color == "green":
print("mine's too!")
print("") #for some space
print(ok bye")
print("chatbot went offline")
4>loops
ok so there are two types of loops one is
for()
and one is while (my favourite)
while()
4.1> for() is used for setting up numbers in order for example
words= ["Apple", "Banana", "Car", "Dolphin" ]
for word in words:
print (word)
4.2> while loops are used for making dangerous loops for example
#be careful this is a very dangerous program
n = 0
while n <=5:
print("the value of n is = " , n)
n ** 1
ok so I couldnt make a whole cheat sheet but please tell in the comments what did I miss but for now like and unicorn this post :)
24