tuomasvaltanen

Untitled

Nov 29th, 2021 (edited)
417
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # more functions today!
  2.  
  3. # our functions file
  4. def print_title():
  5.     print("Welcome to our app!")
  6.     print("-------------------")
  7.     print("Please follow the instructions.")
  8.     print()
  9.  
  10.  
  11. def combine_text(first, last, age):
  12.     print(f"{first} {last}, {age} years old.")
  13.  
  14.  
  15. def get_year():
  16.     year = 2021
  17.     return year
  18.  
  19.  
  20. def get_even_number_text(number):
  21.     if number % 2 == 0:
  22.         return "Even"
  23.     else:
  24.         return "Odd"
  25.  
  26.  
  27. def get_days(hours):
  28.     result = hours // 24
  29.     return result
  30.  
  31.  
  32. def reverse_string(text):
  33.     return text[::-1]
  34.  
  35.  
  36. def check_palindrome(text):
  37.     reverse_text = reverse_string(text)
  38.  
  39.     if text == reverse_text:
  40.         return True
  41.     else:
  42.         return False
  43.  
  44.  
  45. # a validation function for a order code
  46. # it has to be 10 characters long
  47. # first character has to be capital T
  48. def check_order(code):
  49.     okay = True
  50.  
  51.     if len(code) != 10:
  52.         okay = False
  53.  
  54.     if code[0] != "T":
  55.         okay = False
  56.  
  57.     return okay
  58.  
  59.  
  60. def show_vertical_text(value):
  61.     for c in value:
  62.         print(c.upper())
  63.  
  64.  
  65. # a validation function for a order code
  66. # it has to be 10 characters long
  67. # first character has to be capital T
  68. def check_order(code):
  69.     okay = True
  70.  
  71.     if len(code) != 10:
  72.         okay = False
  73.  
  74.     if code[0] != "T":
  75.         okay = False
  76.  
  77.     return okay
  78.  
  79.  
  80.  
  81. # EXERCISE FILE
  82.  
  83. from functions import *
  84.  
  85. # testing our own functions
  86. result = get_year()
  87. print(result)
  88.  
  89. result = get_even_number_text(16)
  90. print(result)
  91.  
  92. reversed = reverse_string("freezing outside")
  93. print(reversed)
  94.  
  95. days = get_days(5682)
  96. print(f"{days} in total!")
  97.  
  98. # ANOTHER FILE
  99.  
  100. from functions import *
  101.  
  102. # ask the word from user and check if it's a palindrome
  103. word = input("Give a word:\n")
  104.  
  105. result = check_palindrome(word)
  106.  
  107. # interpret the result, boolean
  108. if result:
  109.     print("PALINDROME!")
  110. else:
  111.     print("Not a palindrome...")
  112.  
  113. # A NEW FILE
  114.  
  115. from functions import *
  116.  
  117. # ask user for a order code candidate
  118. user_code = input("Give an order code:\n")
  119.  
  120. # check if the code is good or not
  121. result = check_order(user_code)
  122.  
  123. if result:
  124.     print("Valid code!")
  125. else:
  126.     print("Something wrong with the code.")
  127.  
  128. # NEW FILE
  129.  
  130. from functions import *
  131.  
  132. word = input("Give a word:\n")
  133.  
  134. show_vertical_text(word)
RAW Paste Data