Show Menu
Cheatography

Cheat sheet N Cheat Sheet by

Symbols 2

>
more than
<
less than
>=
equal or more than
<=
equal or less than

Vocab

input()
receive inform­ation from user
print()
show info that received from user
int()
change info to integer
float()
convert value into decimal number

Letter Number (Code)

firstname = input("What is your firstname? ")
lastname = input("What is you lastname? ")
fullname = firstname + " " + lastname
print (fullname)

letternum = int(input("What is the letternumber? "))
if len(fullname) >= int(letternum):
    print (fullname[letternum])
    letterprint = int(input("How many times to print the letter? "))
    if int(letterprint) <= 100:
        print (fullname[letternum] * int(letterprint))
    else:
        print ("Too many letters to print!")
else:
    print ("Invalid letter number, try again")
 

Vocab 3

Variable
info from user that can change
Syntax
the computer's grammar

Symbols

==
equal to
!=
not equal to
+
add number
-
minus number
*
multiply number
%
find remainder between two number
/
divide number
**
power the number

Reverse Word (Code)

word = input("Enter a word: ")
index = 0
reverse = ''
while index < len(word):
    reverse = word[index] + reverse
    index = index+1
print("Reverse: ",reverse)

Finding Radius (Code)

user_radius = input("What is your radius ?")

radius = float(user_radius)

pi = 3.1415

area = (pi (radius * 2))

print ("The area of the circle is", area)
 

Guessing Word Game (Code)

import random
mylist = ['barbie', 'kitty', 'my melody', 'sailor moon', 'pretty cure']
random_item = random.choice(mylist)
print(random_item)
print(mylist[0])
print(mylist)

chance = 5
score = 0

while chance > 0:
    user_guess = input("Guess a word ")

    if user_guess == random_item:
        score = score+100
        print ("That's correct")
        print ("score: ", score)
        random_item = random.choice(mylist)
    elif user_guess in mylist:
        chance = chance-1
        print ("Sorry, wrong choice!")
        print ("chance remaining ", chance)
    else:
        chance = chance-1
        print ("Sorry, that's not even on the list")


(chance == 0, print("game over"))

Vocab2

string
inform­ation user added
len()
number of string
boolean
true/false

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.