|
str()
|
make the number or symbol
|
|
input()
|
to get infomation from the user
|
|
print()
|
to show some infomation that in the code
|
|
int()
|
the integers
|
|
len()
|
length of the string
|
|
#
|
comment
|
|
string+string
|
Combine together
|
|
string+number
|
CRASH!
|
|
Number+number
|
Addition(Math)
|
|
string*number
|
Combine the string
|
|
string*string
|
CRASH!
|
|
number*number
|
Multiply(math)
|
|
string**string
|
CRASH!
|
|
number**number
|
Exponent(math)
|
|
string**number
|
CRASH!
|
user_ number = ' '
while user_number != ' 0 ' :
user_number = input ("Enter a number to convert to binary")
number = int(user_number)
binary_string = ' '
while (number > 0):
remainder = number%2
binary_string = str(remainder)+binary_string
number = number/ /2
print ("Binary string is". binary_string)
import random
intlist = [1,2,3,4,5,]
random_int = random.choice(intlist)
print (intlist, random_int)
fplist = [1.5,2.5,3.5,4.5,5.5]
random_fp = random.choice(fplist)
print (fplist, random_fp)
strlist = ['1', '2', '3', '4', '5']
random_str = random.choice(strlist)
print (strlist, random_str)
mylist = [1, 2, 3, 4, 5, 1.5, 2.5, 3.5, 4.5, 5.5,'1', '2', '3', '4', '5' ]
random_item = random.choice(mylist)
print (mylist, random_item)
myvar1 = 1
myvar2 = 2
myvar3 = 3
varlist =[myvar1, myvar2, myvar3]
random_var = random.choice(varlist)
print (varlist, random_var)
|
Variable
|
The unknow that can be change
|
|
String
|
a list of character
|
|
Float
|
Decimal number
|
|
Integer
|
Whole number
|
|
Syntax
|
structure of langauge
|
|
Boolean
|
True/False
|
|
Length
|
the length of the string
|
|
Modulo
|
Finds the remainder
|
|
==
|
equal to
|
|
!=
|
not equal to
|
|
<
|
less than
|
|
>
|
more than
|
|
<=
|
less than or equal to
|
|
>=
|
more than or equal to
|
|
%
|
Modulo, find remainder
|
|
+
|
plus
|
|
-
|
subtract
|
|
*
|
multiply
|
|
**
|
exponent
|
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 ("Reverse:" , reverse)
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.