Advertisement
Guest User

Python Project

a guest
Dec 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.31 KB | None | 0 0
  1. #Created by Hybrid ~ Please don't steal :(
  2. import os
  3. #Reset Function
  4. def reset():
  5.     print("\n" * 2)
  6.     restart()
  7. # User enters a number and then the number and all of the numbers below it are outputed squared
  8. def squarerootlist():
  9.     inp = int(input("Enter a number and that number and all of the numbers below it will be displayed squared: "))
  10.     for i in range(inp):
  11.         if i != 0:
  12.             print(inp * inp, " - ", inp)
  13.             inp -= 1
  14.     print("1  -  1")
  15. #Palindrome Check Test
  16. def reverse(num):
  17.   if int(str(num)[::-1]) == num:
  18.       print("The number",num, "is a palindrome")
  19.       reset()
  20.   if int(str(num)[::-1]) != num:
  21.       print("The number", num, "is not a palindrome")
  22.       reset()
  23. #User's choice
  24. def restart():
  25.     choiceinp = str(input("(For help type Help, if you want to exit, type exit)\nEnter what you'd like to do, (Add - 1, Subtract - 2, Multiply - 3, Divide - 4, Square Root List - 5, Square a Number - 6, Palindrome Check - 7): ")).lower()
  26.     def start():
  27.         if choiceinp == "exit":
  28.             exit()
  29.         if choiceinp == "help":
  30.             print("\n\nType the number you want for the operation you want\n1 - Addition (Type one number, press enter, type another number, press enter for the total)\n2 - Subtraction (Enter a number, press enter, enter another number, press enter for the difference)"
  31.                   "\n3 - Multiplication (Enter one number, press enter, enter another, press enter for the product)\n4 - Division (Enter one number, press enter, type another number, press enter for the quotient)"
  32.                   "\n5 - Square Root List (Enter a number, it will show you the number squared and all of the numbers below it squared)\n6 - Square a Number (Squares a number)\n7 - Palindrome Check (Checks to see if the number is a palindrome or not)"
  33.                   "")
  34.         # This    ^^^ is for more help as more funtions are added
  35.             os.system("pause")
  36.         if choiceinp == "5":
  37.             squarerootlist()
  38.         if choiceinp == "7":
  39.             num = int(input("Enter a number to find out if it's a palindrome: "))
  40.             reverse(num)
  41.         elif choiceinp != "1" or "2" or "3" or "4" or "5" or "6" or "7" or "help":
  42.             os.system("pause")
  43.             restart()
  44.     start()
  45. #Call's the program to be started
  46. restart()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement