Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. # Futures
  2. import keyboard
  3.  
  4. from tkinter import *
  5. # [...]
  6.  
  7. def ageCheck():
  8.     birthYear = int(input('Your birth year: '))
  9.     age = 2020 - birthYear
  10.     print("You are %d years old" % (age))
  11.  
  12. # This program takes the user's birth year as an integral input and stores it as a variable.
  13. # It then subtracts birthYear from 2020 and then prints it out in a statement.
  14.  
  15. def downwardCount():
  16.     n = 5
  17.     try:
  18.         while True:
  19.             print(n)
  20.             n = n - 10
  21.         except KeyboardInterrupt:
  22.             pass
  23.            
  24. def deskLength():
  25.     while True:
  26.         try:
  27.             lengthInInches = int(input("Length of the desk in inches: "))
  28.         except ValueError:
  29.             print("Please print an integer.")
  30.             continue
  31.         else:
  32.             return lengthInInches
  33.             break
  34.  
  35.             #deskLength needs to be rewritten to fix try and except stuff.
  36.  
  37.     lengthInCM = lengthInInches * 2.54
  38.     print("The desk is %d centimetres long" % (lengthInCM))
  39.  
  40. def goodDay():
  41.     x = 1
  42.  
  43.     while x <= 6:
  44.         print("Have a good day")
  45.         x += 1
  46.  
  47. def ticketPrice():
  48.     age = int(input("Your age: "))
  49.  
  50.     if age < 14:
  51.         print("You are a child and must pay $5.00.")
  52.  
  53.     elif age > 65:
  54.         print("You are a senior and must pay $7.00.")
  55.  
  56.     else:
  57.         print("You are an adult and must pay $9.00.")
  58.  
  59. def passOrFail():
  60.     grade = int(input("Your class mark: "))
  61.  
  62.     if grade >= 50:
  63.         print("You passed the course")
  64.  
  65.     if grade < 50:
  66.         print("You failed the course")
  67.  
  68. def speedCheck():
  69.     hours = int(input("Number of hours in trip: "))
  70.     minutes = int(input("Number of additional minutes in trip: "))
  71.     distance = int(input("Distance of trip in kilometers: "))
  72.  
  73.     speed = distance / (hours * 60 + minutes)
  74.  
  75.     print("You are driving at %d km/h." % (speed))
  76.  
  77. def wordCounter():
  78.    
  79.         wordList = []
  80.  
  81.         word = str(input("Enter your word: "))
  82.  
  83.         while word != "exit":
  84.                wordList.append(word)
  85.                word = str(input("Enter your word: "))
  86.        
  87.         wordCount = len(wordList)    
  88.  
  89.         print("You inputted %d words" % (wordCount))    
  90.  
  91.         exit()
  92.  
  93. def integerSizing():
  94.     positiveIntegers = []
  95.  
  96.     while len(positiveIntegers) < 10:
  97.         integer = int(input("Enter Positive Integer: "))
  98.  
  99.         if integer < 1:
  100.             print("Integer must be positive")
  101.             continue
  102.  
  103.         positiveIntegers.append(integer)
  104.  
  105.     positiveIntegers.sort()
  106.     largest = positiveIntegers[-1]
  107.  
  108.     print("The largest number is %d" % largest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement