'How to write Python functions and nested functions?

link to assignment**

This is what I have so far but I cant figure out the rest. I am having a hard time solving the rest of the problem. Like calling sum variables from other functions. If anyone could lend a hand I would appreciate it, thank you.

#hello function
def hello():
  print("***************************************")
  print("***  WELCOME TO THE MAGIC PROGRAM *****")
  print("***************************************")

#get_highest function
def get_highest():
  first_num = int(input("\nEnter first number: "))
  second_num = int(input("Enter second number: "))
  largest_num = 0 
  if first_num > 0 and second_num > 0 and first_num >= second_num:
    print("\nThe largest number is: ", first_num)
    first_num = largest_num
  elif second_num > 0 and first_num > 0 and second_num >= first_num:
    print("\nThe largest number is:", second_num)
    second_num = largest_num
  else:
    print("\nERROR: Both numbers must be greater than 0!")
    print("Try again.")
    get_highest()

    
  return largest_num

  
#odd_or_even function
def odd_or_even(largest_num):
  largest_num = get_highest()
  if (largest_num % 2 == 0):
        print(largest_num, " is an EVEN NUMBER!!")
  else:
        print(largest_num, " is an ODD NUMBER!!")    
      
#print_magic function
def print_magic(largest_num):
  largest_num = get_highest()
  total = 0
  for x in range(1, largest_num):
    total = total + x
  




hello()
get_highest()
odd_or_even()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source