Show Menu
Cheatography

Aom python3 Cheat Sheet (DRAFT) by

Cheat sheets

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Vocabulary

Variable
Hold the value
String
A list of character such as, number, symbol, letters
Integer
Whole number the number that can count
Float
The decimal number.ex 1.00 1.01 2.89
Boolean
True / False
Modulo
Find the Remainder. Ex 5%4 =1 6%4 = 2

Example 2

name = input(­"­Please enter your name : ")
age = input(­"­Please enter your age : ")
height = float(­inp­ut(­"­Please enter your height(Cm) : "))
height /= 100
weight = float(­inp­ut(­"­Please enter your weight(Kg) : "))
gender = input(­"­Please enter your gender : ")

BMI = (weight / height) / height
print (BMI)

message = ("Dear, %s your BMI is %s " % (name, BMI))
print (message)

from datetime import datetime
date = dateti­me.n­ow()
date = "%s / %s" % (date.m­onth, date.year)
print (date)

concat­enate = "Dear %s, your BMI is %s as of %s." % (name, BMI, date)
print (conca­tenate)
x = -(-(-2)) == -2 #true
x = 3 ** 3 >= 26 #true
x = 10 % 9 != 1 #false
x = 33 <= 10 * 3 + 2 #false
x = 3
y = x + 3
print (y)

name = "­Tas­k"
age = 15
print ("Hello %s, I hear your age is %s " % (name, age))
# omsap aom 1008 (Owner)
 

Function

Print()
Display the inform­ation on the screen
Input()
Ask the user for the inform­ation
int()
Convert the value into integer
float()
Change the number into decimal point
str()
To make the number variable or somethings to be the symbol
len()
The length of the string
#
To and the comment, just add not effect the command
"­"­"­___­___­"­"­"
Multiple line comment

Symbol

==
Equal to
!=
Not equal to
<
Less than
>
More than
<=
Less than or equal to
>=
More than or equal to
+
Add
-
Subtract
*
Multiply
/
Divide
**
To the power(­exp­onent)
%
Modulo
.upper()
Upper letter
.lower()
Lower letter
.capit­alize()
Capital
.title()
First letter capital
 

Example 1

# Omsap kongam­orn­pinyo
"­"­"1008 I am very kind"""
x = 3
y = x + 1
print (y**x)
print ((str(x) + str(y)))

name = input ("Name : ")
surname = input(­"­Surname : ")
fullname = name + surname

print (("W­elcome to Computer Science : "), (name), (surna­me[­0].u­pp­er()))

letter = input ("Enter letter number : ")

myletter = int(le­tter)
print (fulln­ame­[my­let­ter])

letter­count = input ("How many times shนuld I print this letter?: ")
mylett­ercount = int(le­tte­rcount)
print ((full­nam­e[m­yle­tter])* (mylet­ter­count))