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
"""Both codes below provide the same output""" | |
def subtractor(a, b): | |
print "I'm a function. My name is {}".format(subtractor.__name__) | |
print "I'm about to subtract {} and {}\n\n".format(a,b) | |
if __name__ == '__main__' # Why is this necessary to have in the code if the output is still the same? | |
subtractor(3, 2) | |
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 | |
#list of strings | |
# assume that a person will only put 1 additional argument | |
# ignore the rest | |
# python Desktop/example_2.py 300 | |
if len(sys.argv) > 1: | |
# user supplied value | |
user_input = sys.argv[1] |
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
user_guess = range(101) | |
while True: | |
user_answer = int(raw_input("Your answer: ")) | |
if user_answer % 3 == 0 and user_answer % 5 == 0: | |
print "Fizz Buzz" | |
elif user_answer % 3 == 0: | |
print "Fizz" | |
elif user_answer % 5 == 0: | |
print "Buzz" |
NewerOlder