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 random | |
import sys | |
print('ROCK, PAPER, SCISSORS') | |
# These variables keep track of the number of wins, losses, and ties. | |
wins = 0 | |
losses = 0 | |
ties = 0 |
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 random | |
def getAnswer(answerNumber): | |
if answerNumber == 1: | |
return 'It is certain' | |
elif answerNumber == 2: | |
return 'It is decidedly so' | |
elif answerNumber == 3: | |
return 'Yes' | |
elif answerNumber == 4: |
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
def a(): | |
print('a() starts') | |
b() | |
d() | |
print('a() returns') | |
def b(): | |
print('b() starts') | |
c() |
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, sys | |
indent = 0 # How many spaces to indent. | |
indentIncreasing = True # Whether the indentation is increasing or not. | |
try: | |
while True: # The main program loop. | |
print(' ' * indent, end='') | |
print('* ******** *') | |
time.sleep(0.1) # Pause for 1/10 of a second. |
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
print("Tell me anything...") | |
anything = input() | |
print("Hmm...", anything, "... Really?") |
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
leg_a = float(input("Input first leg length: ")) | |
leg_b = float(input("Input second leg length: ")) | |
hypo = (leg_a**2 + leg_b**2) ** .5 | |
print("Hypotenuse length is", round(hypo,2)) |
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
print("+" + 10 * "-" + "+") | |
print(("|" + " " * 10 + "|\n") * 5, end="") | |
print("+" + 10 * "-" + "+") |
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
# input a float value for variable a here | |
a = float(input("Value of a: ")) | |
# input a float value for variable b here | |
b = float(input('Value of B: ')) | |
# output the result of addition 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
x = float(input("Enter value for x: ")) | |
# put your code here | |
y = 1/(x+1/(x+1/(x+1/x))) | |
print("y =", y) |
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
hour = int(input("Starting time (hours): ")) | |
mins = int(input("Starting time (minutes): ")) | |
dura = int(input("Event duration (minutes): ")) | |
# put your code here | |
print('Finish Time:', ((hour + (mins+dura)//60)%24), ':', (mins+dura) % 60) |
OlderNewer