Cheatography
https://cheatography.com
Python1
float() |
change to number with decimal |
integer() |
change to number with NO decimal |
Boolean = True/False |
True/False |
print() |
display the information on the screen |
input() |
ask for some information from the users |
len() |
length of the string |
# abcd |
single line comment |
"""abcd""" |
multi-line comments |
Python2
+ Addition |
== equal to |
- Subtraction |
!= not equal to |
* Multiplication |
< less than |
/ Division |
> more than |
** To the power of |
<= less than or equal to |
% Modulo |
>= more than or equal to |
Python3
print() |
display data on the screen |
"....." |
use quotation mark to make it as a string |
string placement |
1st letter = 0 |
print multi variables |
use comma |
blank space counts as a character |
len can be used for STRING ONLY |
Example: juice = "fresh water"
print (len(juice))
>>> 11
|
|
letter
upper |
capital letter; upper() |
lower |
small letter; lower() |
EX: |
x = "hello897" |
|
y = x.upper() |
|
print (y) = "HELLO897" |
dot notation can only be used in STRING ONLY
Concatenation
concatenation |
joining multiple strings together |
Ex: |
phrase = "Task" + "is" + "balding" |
|
print (phrase) >>>> Taskisbalding |
If you enter spaces or gaps |
Ex: phrase = "Task " + "is " + "balding" |
|
print (phrase)>>>> Task is balding |
Be aware of gaps and spaces when using concatenation.
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment