| Math
                        
                                                                                    
                                                                                            | + | plus |  
                                                                                            | - | minus |  
                                                                                            | * | multiply |  
                                                                                            | / | divide give decimal |  
                                                                                            | == | equal to |  
                                                                                            | != | not equal to |  
                                                                                            | < | less than |  
                                                                                            | > | more than |  
                                                                                            | <= | less than or equal to |  
                                                                                            | >= | more than or equal to |  
                                                                                            | % | to find remainder |  
                                                                                            | ** | power |  
                                                                                            | // | divide give integer |  Binary
                        
                                    
                        | 
user_number = input("Enter number to convert to binary : ")
number = int(user_number)
binary_string = ''
while (number > 0):
    remainder = number % 2
    binary_string = str(remainder) + str(binary_string)
    number = number // 2
print ("Binary string is",binary_string)
 |  Radius pi
                        
                                    
                        | while True:
    user_radius = input("Please enter the radius of the circle")
    radius = float(user_radius)
    pi = 3.1415
    area = piradius*2
    print ("The area of the circle is", area)
 |  ==
                        
                                    
                        | myboolean = 2 == 3
if myboolean:
     print ("truth")
else:
     print ("lies")
 |  0,01,012,0123,01234
                        
                                    
                        | mystring = ''"
count = 0
while count <= 4:
    mystring = mystring + str(count)
    print (mystring)
    count = count + 1
mystring = ""
for num in range(5):
    mystring = mystring + str(num)
    print (mystring)
 |  1 * 1 = 1
                        
                                    
                        | def multiplicationTable(num):
    
    multi = 0
    while multi < 10:
        multi = multi + 1
        user_output = num*multi
        print ( num,"*",multi,"=",user_output)
user_num = int(input("Enter the number: "))
multiplicationTable(user_num)
 |  Fibonacci
                        
                                    
                        | num1 = 0
num2 = 1
fibonacci = num1 + num2
output = "0,1"
while fibonacci < 50:
    output = output +","+ str(fibonacci)
    num1 = num2
    num2 = fibonacci
    fibonacci = num1 + num2
print (output)
 |  Boolean
                        
                                                                                    
                                                                                            | False or True | True |  
                                                                                            | False and True | False |  
                                                                                            | True and False | False |  
                                                                                            | True and True | True |  
                                                                                            | False or False | False |  |  | Multiplication and Exponent
                        
                                                                                    
                                                                                            | string * number | Repeat that string by number |  
                                                                                            | string * string | CRASH! |  
                                                                                            | number * number | Multiply (Math) |  
                                                                                            | string ** string | CRASH! |  
                                                                                            | number ** number | Exponent (Math) |  
                                                                                            | string ** number | CRASH! |  String * Numbernum = 1
 stri = str(num)
 
 print (stri * 3)
 ______________
 #After running program
 111
 Hex
                        
                                    
                        | user_number = input("Enter number to convert to hex : ")
number = int(user_number)
hex_string = ''
while (number > 0):
    remainder = number % 16
    if remainder == 10:
        remainder = 'A'
    elif remainder == 11:
        remainder = 'B'
    elif remainder == 12:
        remainder = 'C'
    elif remainder == 13:
        remainder = 'D'
    elif remainder == 14:
        remainder = 'E'
    elif remainder == 15:
        remainder = 'F'
    hex_string = str(remainder) + str(hex_string)
    number = number // 16         
     
print ("Hex string is 0x",hex_string)
 |  Math
                        
                                    
                        | print(2)#interger
print(2.5)#floationg point
print("this is a string")#string
myStr = "hello"
print (myStr)
print ("hello" , 1, 2)
print ("""
hello
yeah
.
.
.
.
""")
"""
This multi line comment #lol
"""
#variable name
#can have interger, lowercase/uppercase letters, underscores
#Mate operators
# + - / *
#exponents
#2 to the power of 3
print (2  2 2 )
print (2 ** 3)
#Modulo/Remainder
print (4%2) #remainder = 0
print (33%2) #remainder = 1
#convert to floating point
print (float(2))
#covert to a string
myint = 1
mystring = str(myint)
print (mystring * 3)
#true/false - Boolean
print (2 < 3)
 |  |  | Addition
                        
                                                                                    
                                                                                            | string + string | Combination of string |  
                                                                                            | string + number | CRASH! |  
                                                                                            | number + number | Add (Math) |  Reverse
                        
                                    
                        | word = input("Please put a word :")
reverse = ""
letternum = 0
while letternum < len(word):
    reverse = (word[letternum]) + reverse
    letternum = letternum + 1
print ("Reverse: ",reverse)
for num in word:
    reverse = num + reverse
print ("Reverse: ",reverse)
 |  Guess
                        
                                    
                        | import random
chance = 3
score = 0
mylist = ['Hack', 'ToeyD.', 'Patter','Tim','Lily']
random_item = random.choice(mylist)
while chance > 0:
    print (mylist)
    
    print ("Chances Remaining =",chance)
    guess = input("Guess a word from the above :")
    
    if guess == random_item:
        score = score + 100
        print ("That's correct!","The score is :",score)
        random_item = random.choice(mylist)
    else:
        print ("Sorry, wrong choice!")
        chance = chance - 1
    if guess in mylist:
        print ("")
    else:
        print ("Sorry,that is not even in the list!")
    if chance == 0:
        print ("Game Over! The word was",random_item)
        print ("Final score: ",score)
 |  Even,Odd number
                        
                                    
                        | even = 0
odd = 0
while True:
    user_num = int(input("Enter the number :"))
    if user_num >= 0:
        if user_num % 2 == 0:
            even = even + 1
        else:
            odd = odd + 1
    else:
        print ("Even number :", even)
        print ("Odd number :", odd)
        break
 |  Definition
                        
                                    
                        | def printDefinition(word):
    if word == "variable":
        print ("""
        A variable is the the thing that can be changed.
        """)
    elif word == "parameter":
        print ("""
        A parameter is the limiting factor
        """)
    elif word == "argument":
        print ("""
        An argument is the identifier that you give to function
        """)
    elif word == "string":
        print ("""
        A string is something that can be repeated by the number.
        """)
    elif word == "function call":
        print ("""
        A function call is the word you use to reuse the function.
        """)
    else:
        print ("unknown word")
while True:
    user_input = input("Please type the word :")
    printDefinition(user_input)
 |  | 
            
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment