Skip to content

Instantly share code, notes, and snippets.

@toddmilne13
Created October 13, 2016 14:31
Show Gist options
  • Save toddmilne13/3dbea2c0df510d7368b56ce9d9f18f84 to your computer and use it in GitHub Desktop.
Save toddmilne13/3dbea2c0df510d7368b56ce9d9f18f84 to your computer and use it in GitHub Desktop.
Here is my Code
def compute_percentage():    print("Example...Tell me the 30% of 100 ")    x = input("Give me the number: ")    number=int(x)    y = input("Give me the percentage to compute(insert only the number without %): ")    percentage = int(y)    result = (number * percentage)/100    print("{0}% of {1} is: {2}".format(percentage,number,result))    print("\n")  def find_percentage():    print("Example... x of y what does represent in percentage ?")    first = input("Give me x: ")    x=int(first)    second = input("Give me y: ")    y = int(second)    result = (x*100)/y    print("{0}% of {1} represents the {2}%".format(x,y,result))    print("\n")    print("This is a small program that you can use to compute and find the percentage of a number...")y=2while(y!=0):    x = input("Insert 1 to compute a percentage\n"              "Insert 2 to find the percentage\n"              "Insert 0 to exit\n")    choice = int(x)     if (choice==1):        compute_percentage()    elif (choice==2):        find_percentage()    elif (choice==0):        print("Bye bye :-)....")        y=0    else:        print("You enter a wrong number...")        evaluation = input("Insert 0 to exit or what you want to continue")        y = int(evaluation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment