-
-
Save beltiras/a47602cb8200f03ed81d100fc791ee6b to your computer and use it in GitHub Desktop.
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 fractions import Fraction | |
# shares price | |
def sharesXprice(stock,valiue): | |
result = stock*valiue | |
divide = valiue % 1 | |
dollar = int(valiue) | |
print("{0} shares with market price {1} {2} have valiue ${3}".format(shares,dollar,divide,result)) | |
continue_ask = True | |
continue_ask = False | |
while True: | |
try: | |
shares = int(input("Enter number of shares: ")) | |
except ValueError: | |
print("Invalid number!") | |
else: | |
try: | |
a,b,c = input("Enter price (dollars, numerator, denominator): ").split(" ") | |
price = Fraction(int(a),1)+Fraction(int(b),int(c)) | |
except ValueError: | |
print("Invalid number!") | |
else: | |
sharesXprice(shares,price) | |
if input("Continue?") == "n": | |
break | |
#result = shares*price | |
#divide = price % 1 | |
#dollar = int(price) | |
#print("{0} shares with market price {1} {2} have valiue ${3}".format(shares,dollar,divide,result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment