Python for Fun

Thoa Shook
3 min readJun 10, 2020

--

I code everyday in my spare time. I find coding is a really interesting thing to explore as a hobby. With my background as an engineer, I often think in an orderly fashion, breaking things down into simpler and smaller steps until each steps is trivial. This skill works wonder when I code. Even when I go deeper in Python, I always look at my first baby’s steps in Python with a smile on my face. The questions are from this source, and I coded in Python using Jupyter Notebook as the platform. Here they are:

  1. Write a program that uses input to prompt a user for their name and then welcomes them.

2. Write a program to prompt the user for hours and rate per hour to compute gross pay.

3. Assume that we execute the following assignment statements: width = 14, height = 8. For each of the following expressions, write the value of the expression and the type (of the value of the expression). a) width//2 b) width/2.0 c) height/3 d) 1 + 2 * 5

4. Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours.

5. Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature.

6. Write a program which repeatedly reads numbers until the user enters ‘done’. Once ‘done’ is entered, print out the sum, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number.

7. Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program.

8. Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following table: score : =1, >=0.9,>=0.8,>=0.7,>=0.6,<0.6 grade:perfect, A, B, C, D, F respectively.

Happy Coding!

--

--