HW: Input, Strings, and Using Functions

Rx: <10 min Av: 10-20 min Sd: 20-30 min DNF: 30+ min

Setup

In PyCharm, create two python files: maths.py & mangle.py.

Don’t forget to add a comment at the top of each program with your name and what the program does.

maths.py

Write a program maths.py that takes a number as input from the user and prints out the following information using the math module:

  1. The floor of the number using the math module (e.g., floor(3.75) is 3)
  2. The absolute value of the number (this should be stored as a variable called absolute_value)
  3. The square root of absolute_value rounded to 2 decimal places
  4. absolute_value times -1

mangle.py

Write a program mangle.py that takes a string as input from the user and prints the string after performing the following operations:

  1. converting the string to all upper case letters
  2. removing the third character
  3. removing the third to last character

For example:

string mangle(string)
hellothere HELOTHRE
42 degrees Celsius 42DEGREES CELSUS

Hints: