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: <Your Name>
# Date Created: 2016/09/05
# Purpose: <brief description>
(*) pseudocode: a notation resembling a simplified programming language, used in
program design.

Solutions

Expert Solution

# Filename: Hwk05_YourLastName.py
# Author: Your Name
# Date Created: 2020/10/06
# Purpose: Learn about user defined function and try except in python
def assign_grade(test_score):
    if test_score>90 :
        return "Ex"
    elif test_score>80 :
        return "A"
    elif test_score>70 :
        return "B"
    elif test_score>60 :
        return "C"
    elif test_score>40 :
        return "D"
    else:
        return "F"


if __name__ == '__main__':
    try:
        test_score = int(input("Enter Test Score? "))
        grade = assign_grade(test_score)
        print("Test Score {}\nGrade {}".format(test_score,grade))
    except ValueError:
        print("Integer required")


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.
which statements are true about Python functions? a)Different functions cannot use same function name b)a function...
which statements are true about Python functions? a)Different functions cannot use same function name b)a function always returns some value c)different function cannot use the same variable names d) function must use the same parameter names as the corresponding variables in the caller what benefits does structuring a program through defining functions bring? a) there is a possibility of reducing the number of variables and/or objects that must be managed at any cost at any one point b)the program is...
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)
Please use python and run in IDLE Question 1 Write functions that do the following: i)...
Please use python and run in IDLE Question 1 Write functions that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both. Question 2 Write functions: i) One that prompts a user for 2 numbers. ii)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT