Created
February 26, 2020 21:33
-
-
Save bennuttall/b69f90259d3fc76d4952990c45eeed5e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sys | |
def foo(n): | |
n = int(n) | |
for i in range(n): | |
print(i + 1) | |
if len(sys.argv) > 1: | |
foo(sys.argv[1]) | |
else: | |
print("Usage: python3 test.py <n>") |
This file contains hidden or 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 sys | |
if len(sys.argv) > 1: | |
if sys.argv[1] == 'color' and sys.argv[2]: | |
color = sys.argv[2] | |
elif sys.argv[1] == 'nocolor': | |
color = 'white' | |
else: | |
print("Usage:") | |
print("python3 test2.py color red") | |
print("python3 test2.py nocolor") |
This file contains hidden or 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 sys | |
if len(sys.argv) > 1: | |
if 'aus' in sys.argv: | |
greeting = "G'day mate!" | |
elif 'usa' in sys.argv: | |
greeting = 'Howdy!' | |
else: | |
greeting = 'Hello.' | |
if 'polite' in sys.argv: | |
seat = 'Please take a seat.' | |
else: | |
seat = 'Take a seat.' | |
print(f"{greeting} {seat}") | |
else: | |
print("Usage:") | |
print("python3 test2.py polite") | |
print("python3 test2.py aus") | |
print("python3 test2.py aus polite") | |
print("python3 test2.py polite usa") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment