Cheatography
https://cheatography.com
function python
print() |
Show information that you want on the screen |
int() |
change number to be number integer |
float() |
change number to be decimal number |
str() |
a list of number, letter and symbols |
symbol math
== |
equal to |
!= |
unequal to |
> |
more than |
< |
less than |
>= |
more than or equal to |
<= |
less than or equal to |
vocabulary
variable |
hold a value and can be change |
input |
gain information from user |
string |
a list of character such as number, letter and symbols |
integer number |
whole number or counting number |
float number |
the number in decimal |
syntax |
grammar or structure of lauguage |
value |
|
|
addition python
string + string |
combine together |
string + number |
crash |
number + number |
math - addition |
multiplication and exponents python
string * number |
combine that string |
string ** number |
crash |
number * number |
math - multiply |
number ** number |
math - exponent |
string * string |
crash |
string ** string |
crash |
|
|
Reverse word
while = loop |
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) |
Convert to Binary
user_number = ' ' |
while user_number != '0' ; |
user_name = 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) |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment