Lab 5b Design and implement an application to convert temperatures from Fahrenheit to Celsius or Celsius to Fahrenheit. Create a menu based application with 3 options, Convert Fahrenheit to Celsius,...

1 answer below »
These are very simply python programming labs that are easily found on U tube. Starting Out with Python Book by Gaddis. Completely read the lab they are just a little different than in the book or on u tube or asking for a few extra lines of code. To be returned as a .py file


Lab 5b Design and implement an application to convert temperatures from Fahrenheit to Celsius or Celsius to Fahrenheit.  Create a menu based application with 3 options, Convert Fahrenheit to Celsius, Convert Celsius to Fahrenheit, and Exit.  You'll need a conditional loop and a sentinel value, (For Example: X to Exit). Celsius to Fahrenheit is       Temperature in Celsius * 1.8 + 32 = Temperature in Fahrenheit Fahrenheit to Celsius is       (Temperature in Fahrenheit - 32) * 5/9 = Temperature in Celsius Create two functions for converting temperatures.  Look for opportunities in the design to implement one or more GLOBAL CONSTANTs. https://www.w3resource.com/python-exercises/python-conditional-exercise-2.php Lab 5 A prime number is a number that is only evenly divisble by itself and 1. For example, the number 5 is prime because it can only be evenlly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 2 and 3. Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number and then prints whether the number is prime. You should use a count controlled for loop to cycle through all of the numbers from 3 to the square root of the number + 1. Something like this:  for i in range(3, int(math.sqrt(number))+1, 2): Notice the step is 2, so you're increasing the value of i by 2 with each pass of the loop.         for counter in range(3, int(math.sqrt(n))+1, 2):             result = n%counter             print("The index is: " + str(counter) + " the number is " + str(n)                   + " and the resulting modulus is: " + str(result))             if n%counter == 0:                 return False         return True Now using your new function, write a program that asks the user for a range of numbers with a start and end point and list all of the numbers that are prime numbers in that range. https://www.youtube.com/watch?v=uSS2qqw41JE&list=PLGFLoZ9w5xCMCvDnylUHIG16hkt90F0sc&index=73 https://www.youtube.com/watch?v=6sa0w-lHI8w&list=PLGFLoZ9w5xCMCvDnylUHIG16hkt90F0sc&index=74 https://www.youtube.com/watch?v=SVK9Q_WEUKM&list=PLGFLoZ9w5xCMCvDnylUHIG16hkt90F0sc&index=75 Lab 4 At one college, the tuition for a full-time student is $8,000 per semester.  It has been announced that the tuition cost per semester will increase by 3 percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition cost per semester for the next 5 years. The program should print output in the this format. The current tuition cost per semester is $8,000.00. In 1 year, the tuition per semester will be $8,240.00. In 2 years, the tuition per semester will be $8,487.20. In 3 years, … In 4 years, … In 5 years, … https://www.slader.com/textbook/9780134444321-starting-out-with-python-4th-edition/205/programming-exercises/10/ Lab 2 You decide to buy some stocks for a certain price and then sell them at another price. Write a program that determines whether or not the transaction was profitable. Here are the details: • Take three separate inputs: the number of shares, the purchase price of the stocks, and the sale price, in that order. • You purchase the number of stocks determined by the input. • When you purchase the stocks, you pay the price determined by the input. • You pay your stockbroker a commission of 3 percent on the amount paid for the stocks. • Later, you sell the all of the stocks for the price determined by the input. • You pay your stockbroker another commission of 3 percent on the amount you received for the stock.    Net Profit = Sales Price - Commission at Sale - (Purchase Price + Commission at Purchase) Your program should calculate your net gain or loss during this transaction and print it in the following format:  Print out the results of the calculations for the profit on the sale of your stock.  We will assume that a positive amount is a gain and a negative amount it a loss. Use string formatting. SAMPLE RUN #1 Interactive Session Enter number of shares:2000 Enter purchase price:40 Enter sale price:42.75 After the transaction, you gained 535.0 dollars. shares = int(input('Enter number of shares:')) purchase_price = float(input('Enter purchase price:')) sale_price = float(input('Enter sale price:')) cost=float(shares*purchase_price) commission=float(cost*.03) total=float(cost+commission) sale_total=float(shares*sale_price) commission_2=float(sale_total*.03) income=float(sale_total-commission_2) profit=float(income-total) if (profit>=int(0)):(print('After the transaction, you gained ' + format(profit) + ' dollars.' )) else:(print('After the transaction, you lost ' + format(profit*-1) + ' dollars.' )) Sample 2 Use string formatting. solution: Enter number of shares 12 Enter purchase price 100 Enter sale price 200 After the transaction, you gained 535.0 dollars. def Calculate(Stock,Purchase,Sell):     # net amount spend for all the stock purchased is     # product of number of stocks * each stock amount(Purchase)     net_amount_spend= Stock*Purchase     #amount given for the stock broker after buying stocks     BrokerCharges=net_amount_spend*3/100     # total amount spend on stocks purchased is net_amount_spend + BrokerCharges     total_spent =net_amount_spend+BrokerCharges     #net amount received for all the stock sell is     # product of number of stocks * each stock sell amount(Sell)     net_amount_receive=stock*Sell     # amount given for the stock broker after selling     BrokerCharges=net_amount_receive*3/100     # total amount received on stocks purchased is net_amount_receive + BrokerCharges     total_receive=net_amount_receive-BrokerCharges     # total amount gain/loss = total amount amount received -total amount spent     net_amount=total_receive-total_spent     # if net_amount is a non negative number then it is a gain     if(net_amount>=0):         print("After the transaction, you made %f dollars" %net_amount)     # else it is loss     else:         print("After the transaction, you lost %f dollars" %net_amount) if __name__=='__main__':     # getting the inputs( nuber os stock ,purchase ,sell)from the console     print("enter number of stocks purchased")     stock = int(input())     print("enter amount paied for stock purchased")     purchase = int(input())     print("enter amount received after the stocks selling")     sell = int(input())     # Calling the Calculate function     Calculate(stock,purchase,sell)
Answered Same DayMar 10, 2021

Answer To: Lab 5b Design and implement an application to convert temperatures from Fahrenheit to Celsius or...

Neha answered on Mar 11 2021
145 Votes
51817/Data.txt
1
2
3
4
6
5
7
9
4
e
r
d
4
5
6
51817/lab 4.py
tuition = 8000
print("The current tuition cost
per semester is $",format(tuition,'10,.2f'))
year = 1
for year in range(1,6):
tuition += tuition * 0.03
if (year > 1):
print("In",year,"years, the tuition per semester will be $",format(tuition,'10,.2f'))
else:
print("In",year,"year, the tuition per semester will be $",format(tuition,'10,.2f'))
51817/lab 5 b.py
def fahToCel():
fahrenheit = float(input("Enter temperature in fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print('%.2f Fahrenheit is: %0.2f Celsius' %(fahrenheit, celsius))
def celToFah():
celsius = float(input("Enter temperature in celsius: "))
fahrenheit = (celsius * 9/5) + 32
print('%.2f Celsius is: %0.2f Fahrenheit' %(celsius, fahrenheit))
def main():
while True:
print("Select one of the options")
print("1. Convert Fahrenheit to Celsius")
print("2. Convert Celsius to Fahrenheit")
print("3. Exit")
choice = int(input())
if choice == 1:
fahToCel()
elif choice == 2:
celToFah()
elif choice == 3:
print("Exiting...")
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here