|
string + string
|
combine together
|
|
string + number
|
crash
|
|
number + number
|
math-addition
|
|
number-number
|
math-subtraction
|
|
number*number
|
math-multiplication
|
|
number/number
|
math-division
|
|
number**number
|
math-exponent
|
|
number%number
|
finding a remainder
|
|
bolean
|
True/False
|
|
#
|
single-line comment
|
|
""""
|
multi-line comment
|
|
str
|
string
|
|
int
|
integer
|
|
float
|
decimal number
|
|
syntax
|
the structure of a program
|
|
syntax error
|
An error in a program that makes it impossible to parse
|
|
len
|
Return the length of an object
|
|
Modulus(%)
|
Show the remainder of the division
|
|
Single Equal (=)
|
assigns the value on the right to a variable on the left
|
|
Double Equal (==)
|
test if the 2 value are the same
|
|
String
|
a series of sentences that the user will use. Usually surrounded by double quotes
|
|
Variable
|
A thing that can be changed
|
|
input
|
convert things you enter
|
|
if/elif/else
|
conditionals
|
|
While
|
loop
|
|
for
|
list all the thing
|
|
!=
|
If values of two operands are not equal, then condition becomes true.
|
|
==
|
test if the 2 value are the same
|
|
<
|
less than
|
|
<=
|
If the value of left operand is less than or equal to the value of right operand, then condition becomes true.
|
|
>
|
greater than
|
|
>=
|
If the value of left operand is greater than or equal to the value of right operand, then condition becomes true.
|
|
import random
|
|
#create a list
|
|
guesslist = ['adam', 'mild', 'levine']
|
|
chance = 3
|
|
score = 0
|
|
print (guesslist)
|
|
while chance != 0:
|
|
random_item = random.choice(guesslist)
|
|
user_input = input("please guess a word: ")
|
|
if user_input == random_item:
|
|
print (that's correct!")
|
|
else:
|
|
if user_input not in guesslist:
|
|
print ("sorry, that's wrong")
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.