Control#
Exercise 1: Paycheck (AUTOGRADER)
Write a program that computes the a simple weekly paycheck for an individual. The user should be prompted for the number of hours worked, and the payrate. If the user works over 40 hours, the hours over 40 hours should be paid at 1.5 times the hourly rate. Print the initial total. Of course, the government taxes employee’s pay. Asusme this tax rate is 20%. Print the amount withheld for taxes. Then print the net amount to be paid to the individual.
Class assignment, answer not provided
Exercise 2: Stock Gain (or loss)
Write a program that allows the user two successive closing prices for a stock. Compute the the daily percentage gain or loss. If the gain was positive, print the message “The stock price increased by” and the percentage increase. If the gain was negative, print the message “The stock price decreased by and the percentage decrease. Otherwise, print “No change to the stock price.”
1day_one_price = float(input("Enter the stock price at the close of the first day: "))
2day_two_price = float(input("Enter the stock price at the close of the second day: "))
3change = (day_two_price - day_one_price) /day_one_price *100
4if change > 0:
5 print("The stock price increased by", change)
6elif change < 0:
7 print("The stock price decreased by", change)
8else:
9 print("No change to the stock price.")
---------------------------------------------------------------------------
StdinNotImplementedError Traceback (most recent call last)
Cell In[1], line 1
----> 1 day_one_price = float(input("Enter the stock price at the close of the first day: "))
2 day_two_price = float(input("Enter the stock price at the close of the second day: "))
3 change = (day_two_price - day_one_price) /day_one_price *100
4 if change > 0:
File ~/Documents/GitHub/jupyternotebooks/venv/lib/python3.14/site-packages/ipykernel/kernelbase.py:1402, in Kernel.raw_input(self, prompt)
1400 if not self._allow_stdin:
1401 msg = "raw_input was called, but this frontend does not support input requests."
-> 1402 raise StdinNotImplementedError(msg)
1403 return self._input_request(
1404 str(prompt),
1405 self._get_shell_context_var(self._shell_parent_ident),
1406 self.get_parent("shell"),
1407 password=False,
1408 )
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.
BMI Calculator
1# Prompt the user for the unit system
2units = input("Enter values in (i)mperial or (m)etric units: ")
3
4# Get weight and height based on selected units
5if units == "i":
6 weight_pounds = float(input("Enter the individual's weight in pounds: "))
7 height_inches = float(input("Enter the individual's height in inches: "))
8
9 # Convert imperial units to metric
10 weight = weight_pounds * 0.453592
11 height = height_inches * 0.0254
12
13else:
14 weight = float(input("Enter the individual's weight in kilograms: "))
15 height = float(input("Enter the individual's height in meters: "))
16
17# Calculate BMI
18bmi = weight / (height ** 2)
19
20# Determine BMI category
21if bmi < 18.5:
22 category = "underweight"
23elif bmi <= 24.9:
24 category = "normal weight"
25elif bmi <= 29.9:
26 category = "overweight"
27else:
28 category = "obese"
29
30# Display BMI and category
31print(bmi, "(" + category + ")")
---------------------------------------------------------------------------
StdinNotImplementedError Traceback (most recent call last)
Cell In[2], line 2
1 # Prompt the user for the unit system
----> 2 units = input("Enter values in (i)mperial or (m)etric units: ")
3
4 # Get weight and height based on selected units
5 if units == "i":
File ~/Documents/GitHub/jupyternotebooks/venv/lib/python3.14/site-packages/ipykernel/kernelbase.py:1402, in Kernel.raw_input(self, prompt)
1400 if not self._allow_stdin:
1401 msg = "raw_input was called, but this frontend does not support input requests."
-> 1402 raise StdinNotImplementedError(msg)
1403 return self._input_request(
1404 str(prompt),
1405 self._get_shell_context_var(self._shell_parent_ident),
1406 self.get_parent("shell"),
1407 password=False,
1408 )
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.