Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_output = "hello world" | |
print(my_output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld { | |
public static void main(String[] args) { | |
String my_output = "Hello world"; | |
System.out.println(my_output); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Prior to Python 3.8 | |
# Assigning a value to variable and then evaluating the expression in different lines | |
python_version = 3.7 | |
print(f'Python version with walrus operator? : {python_version >= 3.8}') | |
print(f'Applicable for Python version: {python_version}') | |
# Reset variable | |
python_version = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Longer version without walrus operator | |
digit_list = [] | |
user_input = input('Type anything other than digits, and this prompt will quit: ') | |
while user_input.isdigit(): | |
digit_list.append(user_input) | |
user_input = input('Type anything other than digits, and this prompt will quit: ') | |
print('The digits entered by user are: ', digit_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep, time | |
def prep_breakfast(): | |
start_time = time() | |
def boil_water(): | |
print(">>> Start to boil water...") | |
sleep(8) # Sleep for 10 secs to mimic water boiling situation | |
print(">>> Water is boiled!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
import asyncio | |
async def prep_breakfast(): | |
start_time = time() | |
async def boil_water(): | |
print(">>> Start to boil water...") | |
await asyncio.sleep(8) # Sleep for 10 secs to mimic water boiling situation | |
print(">>> Water is boiled!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
print(">>> I am just learning how to program") | |
print(">>> Let's do something awesome") | |
sleep(1000) # Certain tasks that are IO-bound or CPU-bound that takes up a long time | |
print(">>> One awesome task is done! Let's do another awesome task!") | |
sleep(1000) # Repeat the process again... until you learn about a better way to do this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from time import sleep | |
print("Program started...") | |
count = 0 | |
while count < 3: | |
sleep(5) | |
print("Calling subprocess...") | |
completed_process = subprocess.run("./check_users.sh", shell=True) | |
# You can then call attribute or methods of completedProcess here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import typing | |
def add_two_integers(a: int, b: int) -> int: | |
return a + b | |
def add_two_integers(a: int, b: int) -> int: | |
start_time = time.time() |
OlderNewer