** |
Operator for power Eg: 5 ** 2 = 25 |
---|---|
If-else statement | `if age < 17: |
print('NO') | |
else: | |
print('YES')` | |
For loop (output starts from 0 ) |
`for i in range(5): |
print(i)` | |
While loop | `i = 1 |
while i <= 10: | |
print(i) | |
i = i + 1` | |
Function | `def bitcoinToUSD(amount, value_usd): |
#--code--# | |
return var` | |
Files | `f = open("file_name", "r") |
print(f.read())` |
`f = open("demofile1.txt", "a") # Append to an existing file f.write("The file will include more text..") f.close()
f = open("demofile2.txt", "w") # Creating and writing to a new file f.write("demofile2 file created, with this content in!") f.close()` | | | |