|
string+string
|
combine together
|
|
string+number
|
crash
|
|
number+number
|
math-addition
|
|
number-number
|
math-substarction
|
|
number*number
|
math-mutiplication
|
|
number/number
|
math-division
|
|
**
|
exponent
|
|
%
|
modulo
|
|
boolean
|
True/False
|
|
#
|
single line comment
|
|
"""
|
multi-line comment
|
|
while True:
|
|
word = input ("Please enter a word")
|
|
index = 0
|
|
reverse = " "
|
|
while int (index) < len(word):
|
|
reverse = word(index )+ (reverse)
|
|
index = int(index)+ 1
|
|
print ("Revears:", reverse)
|
|
str
|
string
|
|
int
|
integer
|
|
float
|
decimal number
|
|
len
|
lengh
|
|
syntax
|
a structure of the program
|
|
print
|
An instruction that causes the Python interpreter to display a value on the screen.
|
|
Variable
|
The name of something that the code has given a value to
|
|
Single Equal (=)
|
assigns the value on the right to a variable on the left
|
|
Double Equal (==)
|
Tests if two things have the same value
|
|
input
|
to convert things you enter as if they were Python code
|
|
user_number = " "
|
|
user_number != "0" :
|
|
user_number = input ("enter a number to convert to binary")
|
|
number = int (user_number)
|
|
binary_string = " "
|
|
if/else
|
conditional
|
|
while
|
loop
|
|
for
|
list all the things
|
|
==
|
test if two values are the same
|
|
<
|
less than
|
|
>
|
more than
|
|
<=
|
if the value of left operand is less than or equal to the value of right operand,then condition becomes true
|
|
>=
|
if the value of left operand is greater than or equal to the value of right operand,then condition becomes true
|
|
import random
|
|
guesslist = ['grape', 'orange', 'apple']
|
|
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')
|
|
score = score+100
|
|
print ('Score: ', score)
|
|
else:
|
|
if user_input not in guesslist :
|
|
print ('Sorry, that isn't even in the list')
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.