Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # more functions today!
- # our functions file
- def print_title():
- print("Welcome to our app!")
- print("-------------------")
- print("Please follow the instructions.")
- print()
- def combine_text(first, last, age):
- print(f"{first} {last}, {age} years old.")
- def get_year():
- year = 2021
- return year
- def get_even_number_text(number):
- if number % 2 == 0:
- return "Even"
- else:
- return "Odd"
- def get_days(hours):
- result = hours // 24
- return result
- def reverse_string(text):
- return text[::-1]
- def check_palindrome(text):
- reverse_text = reverse_string(text)
- if text == reverse_text:
- return True
- else:
- return False
- # a validation function for a order code
- # it has to be 10 characters long
- # first character has to be capital T
- def check_order(code):
- okay = True
- if len(code) != 10:
- okay = False
- if code[0] != "T":
- okay = False
- return okay
- def show_vertical_text(value):
- for c in value:
- print(c.upper())
- # a validation function for a order code
- # it has to be 10 characters long
- # first character has to be capital T
- def check_order(code):
- okay = True
- if len(code) != 10:
- okay = False
- if code[0] != "T":
- okay = False
- return okay
- # EXERCISE FILE
- from functions import *
- # testing our own functions
- result = get_year()
- print(result)
- result = get_even_number_text(16)
- print(result)
- reversed = reverse_string("freezing outside")
- print(reversed)
- days = get_days(5682)
- print(f"{days} in total!")
- # ANOTHER FILE
- from functions import *
- # ask the word from user and check if it's a palindrome
- word = input("Give a word:\n")
- result = check_palindrome(word)
- # interpret the result, boolean
- if result:
- print("PALINDROME!")
- else:
- print("Not a palindrome...")
- # A NEW FILE
- from functions import *
- # ask user for a order code candidate
- user_code = input("Give an order code:\n")
- # check if the code is good or not
- result = check_order(user_code)
- if result:
- print("Valid code!")
- else:
- print("Something wrong with the code.")
- # NEW FILE
- from functions import *
- word = input("Give a word:\n")
- show_vertical_text(word)
Add Comment
Please, Sign In to add comment