Posts

Showing posts from May 17, 2020

Programming for everybody (Python) Certificate

Image
Coursera : Programming for everybody with Python Official website for Coursera: https://www.coursera.org/learn/python M y certificate* Thank you to visit my blog....

Programming for everybody (Python) Assignment 3.3

Coursera   Assignment 3.3 Week 5 Question:- 3.3  Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table: Score Grade >= 0.9 A >= 0.8 B >= 0.7 C >= 0.6 D < 0.6 F If the user enters a value out of range, print a suitable error message and exit. For the test, enter a score of 0.85 Solution:- score = float(input("Enter Score: ")) if(0.0<=score>=1.0):  print("out of range") elif(score>=0.9):  print('A') elif(score>=0.8):  print('B') elif(score>= 0.7):  print("C") elif(score>= 0.6):  print("D") elif(score< 0.6):  print("F") Official website for Coursera: https://www.coursera.org/learn/python

Programming for everybody ( Python) Assignment 3.1

Coursera   Assignment 3.1 Week 5 Question:- 3.1  Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use  input  to read a string and  float()  to convert the string to a number. Do not worry about error checking the user input - assume the user types numbers properly. Solution:- hrs = input("Enter Hours:") h = float(hrs) r=input ("enter time") rate=float(r) if (h>40):  rate1 = (rate * 1.5) * (h-40)     pay = ((h-5)*rate) + rate1 print(pay) Official website for Coursera: https://www.coursera.org/learn/python

Programming for everybody (Python) Assignment 5.2

Coursera: Programming for everybody with Python  Assignment 5.2 Week 7 Question:- 5.2  Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. Solution:- largest = None smallest = None while True:  try:   num = input("Enter a number: ")   if num == "done":    break   #print (num)   num = int(num)   if largest is None or largest < num:    largest = num   elif smallest is None or smallest > num:    smallest = num  except ValueError:   print("Invalid input") print ("Maximum is", largest) print ("Minimum is", smallest) Official website for Coursera: https://www.coursera.org/learn/

Programming for everybody (Python) chapter 5

Image
Coursera   Chapter 5 Week 7 Quiz solutions:- Official website for Coursera: https://www.coursera.org/learn/python

Programming for everybody ( Python) Assignment 4.6

Coursera  Assignment 4.6 Week 6 Question:- 4.6  Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called  computepay()  and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use  input  to read a string and  float()  to convert the string to a number. Do not worry about error checking the user input unless you want to - you can assume the user types numbers properly. Do not name your variable sum or use the sum() function. Solutions:- def computepay(h,r):     if h < 0 or r < 0:         return None     elif h > 40:         return (40*r+(h-40)*1.5*r)     else:         return (h*r) hrs = float(input("Enter Hou