Python Ratchadarin Cheat Sheet by ratchanew
Include all the functions, vocabulary and other important concepts you have learned in Python so far.
Terms/Functions or Definition
A thing complete in itself
Something that can be change
Number including all the decimals
What is the remainder when dividing by 2
Square (the number)
NOT equal to...
Decimals in Python...
Any decimal in python, it will get rid of all except for the 'floats' command
Anything puts under the quotes, will turn into 'INTEGERS'
length (e.g. length of words)
text you want to display to someone, or "export" out of the program you are writing
Contains many words
Allow the user to type in/input something
Comments only (it does not interfered or have any affect with the commands in the programs)
Area of Circle
Python Intro Assignment #2
#Ask the user for a radius of a circle
user_radius = input("What is a radius of a circle?")
#Convert the given radius to a floating point
radius = float(user_radius)
#Make a variable called pi
pi = float(3.1415)
#Calculate the area of the circle using exponents
area = pi(radius*2)
#Display the area of the circle to the user
print ("The area of the circle is", area)
A list of character such as number, letter and symbols ("Under quotes"
Hold a value and can be change
Whole number (Can be positive or negative)
The number with decimals
Grammar/Structure of Language
Find the reminder
user_number = input("What number do you want to count down? ")
number = int(user_number)
countdown_string = ' '
while number > 0:
countdown_number = countdown_string + str(number) + " "
number = number - 1
Covert Decimal to Binary
user_number = '' while user_number != '0' : user_number = input("Enter a number to convert to binary") number = int(user_number) binary_string = '' while(number>0) : remainder = number/2 binary_string = str(remainder) + binary_string number = number//2 print ("Binary string is", binary_string)
Multiplication and Exponents
string * number
Combine that string
string * string
number * number
Math - MULTIPLY
string ** string
number ** number
Math - EXPONENT
string ** number
Download the Python Ratchadarin Cheat Sheet
Your Download Will Begin Automatically in 5 Seconds.