Question

In: Computer Science

HIMT 345 Homework 05: Functions Overview: Examine PyCharm’s “Introduction to Python” samples for Functions. Use PyCharm...

HIMT 345
Homework 05: Functions
Overview: Examine PyCharm’s “Introduction to Python” samples for Functions. Use PyCharm to work along with exercises from Chapter 4. Modify the grade assignment program of Hwk 04 to utilize a function by copying the Hwk04 project and creating the Hwk05 project.
Prior Task Completion:
1. Read Chapter 04
2. View Chapter 04’s video notes.
3. As you view the video, work along with each code sample in PyCharm. The examples used in the video are available for you to experiment with if you downloaded the complete Severance source files for Chapters 3-10.
a) With PyCharm open, locate the .zip file entitled Ch 4 Functions PPT Code Samples.zip.
b) Open each of the project files for that chapter in PyCharm. Note: The code samples are numbered in the order they are covered in the video.
c) Start the video and follow along.
4. Complete Exercises 4.1 – 4.5 (not handed in).
Specifics: PyCharm’s “Introduction to Python” project contains multiple examples giving the basics of conditional expressions (see list at right). Follow the instructions to complete them. (Not handed in.)

Use PyCharm to work along with the video solution for Exercise 4.6 from the textbook. Try to make the same mistakes (and fixes) made by the author. (Not handed in.)
Create a copy of your Hwk04 project file, calling it Hwk05.
1. Highlight the Hwk04 project, select Refactor/Copy.

Important: Do not skip the process of following along with the videos. It is a very important part of the learning process!
2. Give it a New name: of Hwk05 and leave the To directory: in its default state.
Leave the “Open copy in editor” box checked.
3. After clicking OK, if the project fails to open, just open it manually as you would

any project (File | Open | Hwk05 project).
You may immediately delete Hwk04b as it is not needed in this assignment. You may
need to Refactor | Rename both the project name and the existing Hwk04a.py file, as
only the directory was renamed by PyCharm in creating the copy.
Having renamed Hwk04a to Hwk05_YourLastName.py, your task is to determine the
letter grade using a function.
Here is some pseudocode* to guide the process:
(NOTE: The assign_grade function must be declared at the top of the Python file.)
Prompt for the test score, using try-except to verify it is valid
Invoke (call) the function, supplying it the test score and it returning the appropriate
letter grade;

e.g. letter_grade = assign_grade(test_score)
Display the test score and appropriate letter grade.
What to hand in:
Take screen shots of the console window verifying correct handling of bad input as well
as letter grades for one test score in each grade range. Copy the screen shots into a
Word document (filename Hwk05_YourLastName_Screenshots.doc) with your name and
date in the upper right hand corner. Upload the Word doc and the Python program file
(Hwk05_YourLastName.py) to the appropriate assignment in the LMS.
NOTE: As was described in the previous assignment, each Python file you create should

be documented with (minimally) the following three lines at the top of each file:
# Filename: Hwk03.py
# Author:   
# Date Created: 2016/09/05
# Purpose:   
(*) pseudocode: a notation resembling a simplified programming language, used in
program design.

HERE IS HOMEWORK4

# main function
def main():
    test_score = int(input('Enter Your Test Score in the range (0-100) inclusively: '))
    # for incorrect input
    if test_score<0 or test_score>100:
        print('Sorry, Your Input Score is not in the given Range!!! Try another time!!!')
    else:
        # find grade
        if test_score>=90:
            print("Your Grade:", 'A')
        elif test_score>=80:
            print("Your Grade:", 'B')
        elif test_score>=70:
            print("Your Grade:", 'C')
        elif test_score>=60:
            print("Your Grade:", 'D')
        else:
            print("Your Grade:", 'F')

# execution of program starts from here
if __name__ == '__main__':
    main()

OUTPUT

(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: -8
Sorry, Your Input Score is not in the given Range!!! Try another time!!!
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 105
Sorry, Your Input Score is not in the given Range!!! Try another time!!!
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 54
Your Grade: F
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 64
Your Grade: D
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 75
Your Grade: C
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 85
Your Grade: B
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 95
Your Grade: A
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 100
Your Grade: A
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg100.py
Enter Your Test Score in the range (0-100) inclusively: 0
Your Grade: F
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ 
# main() function
def main():
    # prompt first name 
    first_name = input('First name : ')

    try:
        # prompt current age
        cur_age = int(input("Current Age (in years) : "))
    except:
        print("Sorry you didn't inputted correct current age value!!! Try another time")
        return
    
    try:
        # prompt expected life span
        life_span  = int(input("Expected life span (in years) : "))
    except:
        print("Sorry you didn't inputted correct expected life span value!!! Try another time")
        return

    # calculate age in days
    age_days = cur_age * 365
    
    # calculate days left to live
    days_left = (life_span * 365) - age_days

    # print final message
    print(first_name + " you are " + str(age_days) + " days old. You have " + str(days_left) + " days left to live.")

# execution of program starts from here
if __name__ == '__main__':
    main()

OUTPUT

(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg101.py
First name : Chegg Expert
Current Age (in years) : Fifty-Five
Sorry you didn't inputted correct current age value!!! Try another time
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg101.py
First name : Chegg Expert
Current Age (in years) : 26
Expected life span (in years) : Fifty-Five
Sorry you didn't inputted correct expected life span value!!! Try another time
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ python chegg101.py
First name : Chegg Expert
Current Age (in years) : 26
Expected life span (in years) : 75
Chegg Expert you are 9490 days old. You have 17885 days left to live.
(base) avianjjai@avianjjai-Vostro-3578:~/Desktop/Chegg$ 

Solutions

Expert Solution

Program of Test Grading:

test_score = int(input('Enter Your Test Score in the range (0-100) inclusively: '))

    

    if test_score<0 or test_score>100:

        print("Sorry, Your Input Score is not in the given Range!!! Try another time!!!")

    else:

        if test_score>=90 and test_score<=100:

            print("Your Grade: A")

        elif test_score>=80 and test_score<=89:

            print("Your Grade: B")

        elif test_score>=70 and test_score<=79:

            print("Your Grade: C")

        elif test_score>=60 and test_score<=69:

            print("Your Grade: D")

        else:

            print("Your Grade: F")


Related Solutions

HIMT 345 Homework 05: Functions Overview: Examine PyCharm’s “Introduction to Python” samples for Functions. Use PyCharm...
HIMT 345 Homework 05: Functions Overview: Examine PyCharm’s “Introduction to Python” samples for Functions. Use PyCharm to work along with exercises from Chapter 4. Modify the grade assignment program of Hwk 04 to utilize a function by copying the Hwk04 project and creating the Hwk05 project. Prior Task Completion: 1. Read Chapter 04 2. View Chapter 04’s video notes. 3. As you view the video, work along with each code sample in PyCharm. The examples used in the video are...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm...
HIMT 345 Homework 06: Iteration Overview: Examine PyCharm’s “Introduction to Python” samples for Loops. Use PyCharm to work along with a worked exercise from Chapter 5. Use two different looping strategies for different purposes. Prior Task Completion: 1. Read Chapter 05. 2. View Chapter 05’s video notes. 3. As you view the video, work along with each code sample in PyCharm using the Ch 5 Iteration PPT Code Samples.zip. Important: Do not skip the process of following along with the...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
1. what is the best wavelength to use to examine the smallest visible samples? Why? 2....
1. what is the best wavelength to use to examine the smallest visible samples? Why? 2. If the resolution of an FTIR depends on the distance the mirror travels, why are relatively long moving distances such as 2 or 4 cm not used? What is the trade-off? 3. Which of the three contributing factors to band broadening in chromatography is independend of the flow rate? Explain why.
Homework #3-2 a) (Use software for this problem) Four independent samples are collected form four normally...
Homework #3-2 a) (Use software for this problem) Four independent samples are collected form four normally distributed populations. The data are:         Group 1:       12     11     14     10     12     10         Group 2:       14     12     16     15         Group 3:       17     18     20     22     23         Group 4:       10     9       13     13 The SST is equal to 305.68. Conduct a test...
Examine the Sales functions in QuickBooks for managing customers and sales. Use one (1) scenario or...
Examine the Sales functions in QuickBooks for managing customers and sales. Use one (1) scenario or example to explain a feature or function that will help you make better management decisions in regard to managing customer & sales activities.
Examine the customer and vendor functions in QuickBooks. Use one (1) scenario or example to explain...
Examine the customer and vendor functions in QuickBooks. Use one (1) scenario or example to explain a feature or function that will help you make better management decisions in regard to customers and vendors.
Directly using mathematical expression, DO NOT USE the built-in Python functions, evaluate the binomial function for...
Directly using mathematical expression, DO NOT USE the built-in Python functions, evaluate the binomial function for n = 20, p = 3/8. Make sure you plot your results (Remember the the binomial distribution is discrete)
Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger...
Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger Shack" Per the client, you have the following information: the client’s name, burger’s name, time of the day, and the total bill. By the end of the day, your program will provide the following information: 1. Top three best clients (highest bills) 2. Name of the client with the second-to-last lowest bill 3. Busiest hour of the day (number of clients) Assumptions: 1. doesn't...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could only include alphabetic letters and space. There are 26 alphabetic letters. Consider space the 27th letter. The user then enters a shift code that should be an integer between -26 and 26. The application will show the encoded/decoded message based on the shift code entered. If you encode a message, each letter in the message will be moved forward through the alphabet according to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT