3 Replies - 4893 Views - Last Post: 06 June 2010 - 05:31 PM Rate Topic: -----

#1 marklewis  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 1
  • Joined: 04-June 10

Python: Here's My Homework

Posted 04 June 2010 - 09:11 AM

Hi everyone am an undergraduate student at Portsmouth University, hampshire, United Kingdom. Please I need help with my Puthon coursework. Actually I've been re-taking my python programming unit since 1st semester of year 1 and still struggling to pass the unit. Please am asking if someone here with good knowlwdge of python can help me with my work. I will be forever greatful for the favour.

Here is the work to be completed

Program 2

Money. A company pays its salesman £10 commission for every product sold. If more than 50 products are sold in a week, each extra sale earns £15 commission. If more than 100 products are sold, each extra sale earns £20. Write a program to input the number of products sold and calculate and print out how much is earned.

Program 3


Marks. Write a program that processes a number of student’s marks. The first is an exam mark in the range 0 - 60, the second mark a coursework in the range 0 - 40. Write code that checks that each mark is valid, and asks the user to re-input the data if not valid. Then add the two marks together to form a mark out of 100, and assign it to either a fail, pass, merit, or distinction (Under 40 is a fail, 40 or above a pass, 60 or above a merit, 70 or above a distinction)

The program should make use of a loop to allow the user to process as many student marks as they choose

Program 4

Pizza. You have already written a ‘pizza’ program to calculate the ‘value’ of a pizza. Now rework it, so that it utilises 4 functions – the first validates that the pizza size is between 6 and 15 inches, the second validates a (positive) cost, the third calculates the area of the pizza, and the fourth calculates the cost per square inch.

The structure of the program will look like this:

def Pizza():
size = validateSize(“Enter diameter of pizza (6 – 15) : ”);
cost = validateCost()
area = calcArea(size);
unitCost = perSqInch(area);
print “A pizza”, size,”inches in diameter has a unit cost of £”, \
unitCost,”per square inch”;

# function validateCost – gets and returns a positive float value
def validateCost():
<you complete>

#function validateSize(prompt) - accepts a prompt from main program, and # asks user to input a valid size (6 – 15 inches). Returns a valid size
def validateSize():
<you complete>

#function calcArea accepts a ‘size’ parameter, calculates and returns the area
def calcArea(size):
<you complete>

#function perSqInch accepts parameters ‘area’ and ‘cost’, returns unitCost
def perSqInch(area, cost);
<you complete>

Program 5
Speed Gun. The speeding ticket fine policy in Podunksville is $50 plus $5 for every mph above the speed limit up to 90. Speeds over 90 are also fined an additional $200. Write a program to
- accept a value for the speed limit for the selected stretch of road
- then, within a loop:
- get the clocked speed of each car as it passes the radar gun (this value typed in each time by the user).
- calculate and print either that the speed was legal, or print the amount of the fine, or print an error message (Constraints: the speed radar cannot cope with speeds under 1 (car is stationary or reversing, or over 120 (outside technical capabilities). In either situation, print out an error message, but do not process it.)

Typical Output:

This program calculates a speeding fine

Enter the speed limit on this stretch(mph) : -50
- invalid speed limit -50, must be greater than 0
Enter the speed limit on this stretch(mph) : 50
- starting to process car data

Enter the clocked speed of the next car(mph) : 50
50 mph - within speed limit of 50
Process another car (y/n )? Y

Enter the clocked speed of the next car(mph) : 51
51 mph - exceeds speed limit of 50 mph. Fine is $55
Process another car (y/n ): y

Enter the clocked speed of the next car(mph) : 90
90 mph - exceeds speed limit of 50 mph. Fine is $250
Process another car (y/n ): y

Enter the clocked speed of the next car(mph) : 91
91 mph - exceeds speed limit of 50 mph. Fine is $455

Process another car (y/n ): y
Enter the clocked speed of the next car(mph) : 150
Speed 150 is outside working parameters of the equipment

Process another car (y/n ): n
End of speed trap.

Is This A Good Question/Topic? -5
  • +

Replies To: Python: Here's My Homework

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,436
  • Joined: 23-August 08

Re: Python: Here's My Homework

Posted 04 June 2010 - 09:18 AM

Unless you produce some code of your own showing you've made a REAL effort at these tasks, this topic will be closed. Please note our rules, which you seem to have missed in the big red box while you were posting:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
Was This Post Helpful? 0
  • +
  • -

#3 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Python: Here's My Homework

Posted 05 June 2010 - 08:23 AM

Call the post a joke or a test and walk away with some pride intact.
Was This Post Helpful? 0
  • +
  • -

#4 cnampheonix  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 63
  • Joined: 03-December 09

Re: Python: Here's My Homework

Posted 06 June 2010 - 05:31 PM

If you've taken this for a while and are still struggling, Computer Science may not be for you. From here on it only gets more challenging.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1