Show Menu
Cheatography

boomk Cheat Sheet by

additon

string­+string
combine together
string­+number
crash
number­+number
math-a­ddition

functions

print()
displays inform­­ation on the screen
intput()
receives inform­­ation from the user
int()
converts a value to an integer
float()
change the number into decimal
len()
count the string
str()
change the value into string

codes

print (name.u­pp­er())
print (name.l­ow­er())
print (name.c­ap­ita­lize())
print (name.t­it­le())
 

vocabulary

varible
holds a value and can be changed
string
a list of characters such as numbers, letters, symbols

math symbols

==
equal to
!=
not equal to
+
plus
-
minus
*
times
/
divide
%
remainder
**
power
<
lessthan
>
more than
<=
less than or equal to
>=
more than or equal to

function loop-

def creatlist (quitword):
    print('keep entering words to add to the list')
    print('quit when word=', quitword)

    mylist = []

    while True:
        user_word = input('enter a word to add to the list')

        If user_qord == quitwords:
            return my list

        dulplicateword = False

        for item in mylist
          if item == user_word
          duplicateword == true


        if (duplicatedword == True):
            print ('duplicate word!')
        else:
            mylist.append(user_word)
        

userlist = createlist("hello")
print(userlist)
 

Multip­­li­c­ation and Exponents

string * number
combine that string multiple times
string * string
crash
number * number
math multiply
string ** string
crash
number ** number
math exponents
string ** number
crash

python shop code

print ("welcone to our shop")
price=0
size=('s','m','l','xl')
colour=('red','black','white')
sock=('want','not want')

print (size)
shirt = (input('what shirt size do you want?'))
if shirt == ('s'):
        price = price+70
        print( "the price now is",price)
elif shirt ==('m'):
        price = price+80
        print( "the price now is",price)
elif shirt ==('l'):
        price = price+90
        print( "the price now is",price)
elif shirt ==('xl'):
        price = price+100
        print( "the price now is",price)
else:
        print("our shop doesn't have this size.")


print (colour)
shirtcolour= (input('what colour of shirt do you want?'))
if shirtcolour == ('red'):
        price = price+70
        print( "the price now is",price)
elif shirtcolour ==('black'):
        price = price+80
        print( "the price now is",price)
elif shirtcolour ==('white'):
        price = price+90
        print( "the price now is",price)
else:
        print("our shop don't have this colour")

print (size)
pant = (input('what pant size do you want?'))
if pant == ('s'):
        price = price+70
        print( "the price now is",price)
elif pant ==('m'):
        price = price+80
        print( "the price now is",price)
elif pant ==('l'):
        price = price+90
        print( "the price now is",price)
elif pant ==('xl'):
        price = price+100
        print( "the price now is",price)
else:
        print("our shop doesn't have this size.choose again")
 

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.