Cheatography
https://cheatography.com
Something cheapprint()  Show the information you want on the screen  input()  Change number to be number integer  str()  A list of number letter and symbol  float()  change number to be decimal number  len()  the length of the string 
LOL there no such thing as note
Math== equal to != no equal to < less than > more than <= less than or equal to >= more than or equal to % Modulo, Find the remainder 
Area of circle"" Python Intro Assignment #2 name student number """ #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) 
Countdown machineuser_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 #print(number) print (countdown_string) 
Print Namename = "tim GIRARD" print (name.upper()) → TIM GIRARD print (name.lower()) → tim girard print (name.capitalize()) → Tim girard print (name.title()) → Tim Girard 
  apichatVariable  Hold a value and can be change  string  a list of character such as number letter and symbol  Syntax  Grammar and structure of languge  Integer number  counting number  float number  the number in decimal  modulo  find the remainder 
Addition and multiplication and Exponetstring + string
Combine together
string + number
CRASH!
number + number
Addition (Math)
string * number
Combine that string
string* string
CRASH!
number * number
Multiply (Math)
string ** string
CRASH!
number ** number
Exponent (Math)
string ** number
CRASH!
Sort word per linemystr = "Hello" letter_num = 0 while letter_num < len(mystr): print (mystr[letter_num]) letter_num = letter_num + 1 H e l l o 
sort of fruit listfruits = [] #an empty list for number in range(5): user_fruit = input("Please enter a fruit") fruits.append(user_fruit) print ("Size of fruit list is", len(fruits)) fruits.sort() for fruit in fruits: print ("Fruit: ", fruit) 
sort of fruit listfruits = [] #an empty list for number in range(5): user_fruit = input("Please enter a fruit") fruits.append(user_fruit) print ("Size of fruit list is", len(fruits)) fruits.sort() for fruit in fruits: print ("Fruit: ", fruit) 
  teaw cheat Exampleprint(2)  integer  Print(2.5)  floating point  Print (Hello)  string  print(mystr)  variable 
Namming CoventionRule for giving name  letter  numbers  underscore _ Valid name  _myStr  my3  Hello_there Invalid name  3my=”hi”  cannot start with number  first name=”hi”  firstname  first+name 
Reverse wordwhile True: word = input("Please enter a word") index = 0 reverse = ' ' while int(index) < len(word): reverse = word[index] + (reverse) index = int(index) + 1 print ("Reverse: ", reverse) 
convert to binaryuser_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) 
Area of circlePython Intro Assignment #2 name student number """ #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) 
Area of circlePython Intro Assignment #2 name student number """ #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) 

Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment