Python
/
Language
- 1 Language 9
-
Hello World S
-
Variables S
-
Functions S
-
Conditional A S
-
Operators S
-
While S
-
Turtle S
-
Script Mode S
-
Debugging S
- 2 Strings 7
-
Slice S
-
Raw Strings S
-
Regex A S
-
Validation S
-
Config S
-
Security S
-
Encrypt A S
- 3 Collections 6
-
Lists S
-
Dictionaries S
-
Efficiency S
-
Tree S
-
Tuples S
-
References S
- 4 Functions 5
-
Recursion S
-
Factorial S
-
Modulus S
-
Reassignment S
-
Approximate S
- 5 Storage 8
-
Files S
-
Databases S
-
Pipes S
-
With open S
-
Shelve A S
-
Zip S
-
Csv S
-
Json S
- 6 Class 4
-
Definition S
-
Attributes S
-
Functional S
-
Methods S
- 7 Goodies 5
-
Conditional Expression S
-
List Comprehension A S
-
Generator S
-
Named Tuple S
-
Modules S
- 8 Applications 5
-
Pythagora A S
-
Palindrome A S
-
Binary Search A S
-
Conway Game A S
-
Coin Flip A S
- 9 Scheduler 4
-
Time S
-
Multithreading A S
-
Subprocess S
-
Logging S
- 10 Packages 6
-
Clipboard A S
-
Ocr A S
-
Socket S
-
Image S
-
Virtualenv S
-
Jupyter S
S
R
Q
Python Language Operators
Exponential operation ** Bitwise operator ^ 6**2 #36 6^2 #4
Operators
1 p23 Arithmetic operations - exponential ** / Bitwise operator - XOR ^
# Exponential
n = 6**2 + 6
print(n)
# 42
# Bitwise XOR
n = 6^2
print(n)
# 4
# Division
n = 105 / 60
print(n)
# 1.74
# Floor Division
n = 105 // 60
print(n)
# 1
# Remainder example - with floor division
minutes = 105
hours = minutes // 60
remainder = minutes - hours*60
print(remainder)
#45
# Remainder example - with modulo
minutes = 105
remainder = 105 % 60
print(remainder)
# 45
Time
Convert GMT time since Unix time.
# The time module provides a function ...
# that returns the current GMT in “the epoch”
#
# Let's write a function that returns ...
# days, hours, minutes, seconds since Unix birthday 01.01.1970
import time
today = time.time()
print(today)
# 1636720824.934335
def convert_GMT(t):
days = int(t) // (3600 * 4)
remainder = int(t) % (3600 * 4)
hours = remainder // 3600
remainder = remainder % 3600
minutes = remainder // 60
remainder = remainder % 60
seconds = remainder
return (
str(days) + " days " + \
str(hours) + " hours " + \
str(minutes) + " minutes " + \
str(seconds) + " seconds"
)
print(convert_GMT(today))
# 113661 days 0 hours 50 minutes 32 seconds
➥ Questions