usmiwka80

1. Data Type (another solution)

Dec 13th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | Software | 0 0
  1. def type_int(symbol):
  2.     num = int(symbol)
  3.     return num * 2
  4.  
  5.  
  6. def type_real(symbol):
  7.     num = int(symbol)
  8.     return num * 1.5
  9.  
  10.  
  11. def type_string(symbol):
  12.     greeting = '$' + symbol + '$'
  13.     return greeting
  14.  
  15.  
  16. type_line = input()
  17. new_symbol = input()
  18. if type_line == "int":
  19.     print(type_int(new_symbol))
  20. if type_line == "real":
  21.     print(f"{type_real(new_symbol):.2f}")
  22. if type_line == "string":
  23.     print(type_string(new_symbol))
Advertisement
Add Comment
Please, Sign In to add comment