Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Functions and Debugging
- Проверка: https://judge.softuni.bg/Contests/Compete/Index/922#6
- 07. Greater of Two Values
- Условие:
- You are given two values of the same type as input. The values can be of type int, char of string.
- Create a function that returns the greater of the two values:
- Examples
- Input:
- int
- 2
- 16
- Output:
- 16
- Input:
- char
- a
- z
- Output:
- Z
- Input:
- string
- Ivan
- Todor
- Output:
- Todor
- Hints
- 1. For this function you need to create three functions with the same name and different signatures
- 2. Create a function which will compare integers.
- 3. Lastly you need to create a function to compare the other types.
- 4. The last step is to read the input, use appropriate variables and call the function you’ve just written.
- """
- type_value = input()
- value1 = input()
- value2 = input()
- def int_values():
- if int(value1) > int(value2):
- print(value1)
- else:
- print(value2)
- def char_values():
- if ord(value1) > ord(value2):
- print(f"{value1}")
- else:
- print(f"{value2}")
- def str_values():
- if value1 > value2:
- print(value1)
- else:
- print(value2)
- def checker():
- if type_value == "int":
- int_values()
- elif type_value == "char":
- char_values()
- elif type_value == "string":
- str_values()
- checker()type_value = input()
- value1 = input()
- value2 = input()
- def int_values():
- if int(value1) > int(value2):
- print(value1)
- else:
- print(value2)
- def char_values():
- if ord(value1) > ord(value2):
- print(f"{value1}")
- else:
- print(f"{value2}")
- def str_values():
- if value1 > value2:
- print(value1)
- else:
- print(value2)
- def checker():
- if type_value == "int":
- int_values()
- elif type_value == "char":
- char_values()
- elif type_value == "string":
- str_values()
- checker()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement