# We Helped With This Python Programming Assignment: Have A Similar One?

SOLVED
Category Programming Python Undergraduate Solved Python Assignment

## Short Assignment Requirements

Every requirement is included in the assignment attached.

## Assignment Description

Lab: Modules

### Overview

This lab introduces modules, which allow the usage of functions from different files. You've already seen the use of module import, as random, math, and scipy. Imagine a large program that calls several different functions you've defined within it. Now, you'd like to make a second program – and many of the functions in the first are very helpful in the second. You could rewrite them again in the second program, or simply import them, which allows access to them without having to rewrite anything.

Here we will import functions you've written to illustrate how importing works. As long as both files are in the same directory, it can be imported. Python also has a special directory within its installation folder that stores packages that are installed from the web or elsewhere (like SciPy). When using the import keyword, this directory as well as the directory you're working in are searched for the module.

### Lab Activities

Exercise 1: Creating a Function

Exercise 2: Importing a Function

### Exercise 1: Create a Function to Calculate the Cost of Gas

Overview: In the drive to work program, we have been asking the user for the cost of gasoline, but haven’t put that variable to use. We will make a function now that takes in cost, distance, the usage rate, and returns a total.

 1. Open function_test.py from last lab. •     Reopen the function_test.py program. If you haven’t closed it, it should exist as a tab in Spyder.•     If you have lost this file, just create a new blank file.•     Clear out the main portion of this file, leaving only the function definitions. 2. Define a function calc_price(cost, distance,rate): •       Recall, rate is in distance per unit of fuel.•       You will need to calculate the units of fuel for a given distance, multiply that by cost, and return the value.•       Create a DocString for this function ("""underneath the def line, with triple quotes""") that describes what it does.•       Test your function within this program to verify it calculates properly, e.g.:•       calc_price(3,100,200) should return 6.0 3. Import your new function to another program. •     Open any of the programs we've created before, or open a new file.•     Because Spyder saves all of these files in the same directory, they all have access to each other using import.•     Type import function_test near the top of this file. You now have access to those functions! •       Now, anywhere within the main portion of this program, type:•       function_test.•       Anaconda will list the available functions. You should have do_exp (if you used your last function_test.py) and calc_price. Also you have access to random, since it was imported for function_test.py.•       Choosing calc_price, clicking the word so the cursor is within it, and hitting Ctrl+I shows the DocString you wrote earlier.•       Try calling one of those functions and running the program. Remember to use print lines where necessary to verify results.

### Exercise 2: Import the Function into Branching.py

Overview: We will now implement our function into the Drive to Work program stored in branching.py.

 1. Import your function into branching.py •       Open branching.py and import function_test. Remember imports should happen at the top of the program underneath. •       Verify it is usable by typing: function_test. Spyder should show you the available functions.•       Call your calc_price function above the while loop for review, using the appropriate values taken from the user.•       Add a print line within the review section that reports the total cost of the trip, based on the value returned by function_test.calc_price().•       Remember to use the appropriate format specifiers for currency!•       You can also add to the #reporting strings section in case the user doesn't want to review the values, but would still like to know how much they expect to spend on this trip. 2. Test your program •     Run the program and verify it works as intended.•     If you have issues, make sure indentation is correct (Remember, we have multiple loops!)

Is it free to get my assignment evaluated?

Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.

How much does it cost?

The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):

 Regular homework \$20 - \$150 Advanced homework \$100 - \$300 Group project or a report \$200 - \$500 Mid-term or final project \$200 - \$800 Live exam help \$100 - \$300 Full thesis \$1000 - \$3000

How do I pay?

Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.

Why do I need to pay in advance?

We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.

Do you do essays?

No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.

Why there are no discounts?

It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for \$100, we could tell that the price is \$200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.

Do you do live tutoring?

No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.

What happens if I am not satisfied with the solution?

Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.

## Popular Solved Assignments Like This

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On