Write a function that will print the details of a player

Assignment Help Python Programming
Reference no: EM132185596

ASSIGNMENT -

This assignment comprises two exercises.

Exercise 1 -

The attributes of a football player are name, last name, position, team and salary.

In the file ex1.py write a function which takes a string argument, and creates and returns a tuple containing details of the player specified by the string. The string should be assumed to have the format

Chelsea Right-back Davide Zappacosta 20,000,000

The tuple will contain the fields in the following order: team, position, name, lastname and salary. The tuple should contain exactly 5 items.

Next, write a function that will print the details of a player on a single output line. It should take a tuple as its argument and print the details in fixed-width fields using a layout such as

Zappacosta, Davide 20,000,000 Right-back Chelsea

The name must be displayed in a single fixed-width field using the format shown above so you will need to create a string containing the name in this format and print it in a fixed- width field. You may assume that no name will contain more than 30 characters when displayed in this format, position will contain more than 15 characters, salary will contain at most 8 digits.

In the main body of the program, write code which prompts the user for a filename and attempts to open the file whose name is supplied. If the file cannot be opened an error message should be output and the program should terminate; otherwise the program should read each line from the file and supply it to the player tuple-creation function, storing the tuples returned by this function in a list. You may assume that the file contains lines that conform to the format described for the argument to the function.

After the data has been input the program should display details of all the players in the list in a neat table (using the function already written) then enter a loop in which the user should be given the option of requesting the display of (a) full details of (i) the player with a given lastname or (ii) all players with a salary in a particular range (e.g. 20000 to 30000) or (b) the first and last names of all players of a team or quitting the program.

The user should then be asked to supply the position, team or lower and upper bounds of the salary range (as appropriate), the list should then be searched, and the appropriate output displayed (using the function written earlier when full details are required). The salary output should be sorted numerically in ascending order of salary. Appropriate messages should be displayed if a search produces no results. The user should be told what has to be typed in order to select each option; the input options should be concise (e.g. '1', '2' etc. or 'j', 's' etc.) in order to allow quick testing of the program.

Exercise 2 -

The attributes of a city are name, latitude, longitude and number of citizens.

In the file ex2.py write a function which takes a string argument, and creates and returns a tuple containing details of the city specified by the string. The string should be assumed to have the format

Rome 111000 20000 1200000

The items in the tuple will be name, latitude, longitude, and number of citizens. You can assume that latitude and longitude are 2D coordinates in KM, not degrees. The tuple should contain exactly 4 items.

Next, write a function that will print the details of a city on a single output line. It should take a tuple as its argument and print the details in fixed-width fields using a layout such as

Rome n. citizens: 1,200,000

The name must be displayed in a single fixed-width field using the format shown above so you will need to create a string containing the name in this format and print it in a fixed- width field. You may assume that no name will contain more than 30 characters when displayed in this format, the number of citizens will contain at most 8 digits.

In the main body of the program, write code which prompts the user for a filename and attempts to open the file whose name is supplied. If the file cannot be opened an error message should be output and the program should terminate; otherwise the program should read each line from the file and supply it to the player tuple-creation function, storing the tuples returned by this function in a list. You may assume that the file contains lines that conform to the format described for the argument to the function.

After the data has been input the program should display details of all the cities in the list in a neat table (using the function already written) then enter a loop in which the user should be given the option of requesting the display of (a) full details of (i) the city with a given name or (ii) all the cities with a population in a particular range or (b) the city, if any, within 10Km from the coordinates specified by the user.

The user should then be asked to input 2 cities names, and the program should be able to compute the distance between the cities using the information about longitude and latitude.

Reference no: EM132185596

Questions Cloud

Difference between actual authority and implied authority : What is the difference between actual authority and implied authority? Is the government bound by implied authority?
About midwest flawed outsourcing strategy : She hadn't been able to sleep and her head hurt. he wondered what she was going to do about Midwest's flawed outsourcing strategy.
General health care fraud prevention and enforcement action : Visit the Office of Inspector General Health Care Fraud Prevention and Enforcement Action Team (HEAT) Provider Compliance Training Web page
Reported occurrence of identity theft : Identify the measures you can employ to prevent identity theft and discuss how you would respond to a reported occurrence of identity theft.
Write a function that will print the details of a player : CE151 ASSIGNMENT - Write a function which takes a string argument, and creates and returns a tuple containing details of the player specified by the string
Identifying interrelated projects within an organisation : What are the questions you can ask when identifying interrelated projects within an organisation?
What would you recommend regarding this conflict : What do you think of the soft drink industry’s stance or position? what would you recommend regarding this conflict?
Requirements prior to short-term and long-term suspension : Essay summarizing the due process requirements prior to a short-term and a long-term suspension of a student at that site.
Explain importance of maintaining accurate employee records : Explain the importance of maintaining accurate and objective employee records, indicating the consequences that may result from lack of record keeping.

Reviews

len2185596

12/4/2018 8:55:19 PM

Deadline: 11.59.59, 10th. Submission of this assignment will be via FASER; you will not be required to demonstrate your programs in the lab. It is expected that marks and feedback will be returned by the middle of week 17. You should refer to sections 5 and 7 of the Undergraduate Students’ Handbook for details of the departmental policy regarding late submission and plagiarism; the work handed in must be entirely your own. This assignment comprises two exercises, to be written as separate programs in files called ex1.py and ex2.py. Each will contribute 45% of the mark. The remaining 10% of the total mark for the assignment will be awarded for programming style and documentation. Sample data files to be used for testing the programs will be supplied.

Write a Review

Python Programming Questions & Answers

  Generated Web Site for Aussie Road Fatalities

ICT112 Assignment. University of the Sunshine Coast. Write a Python program that generates an informative web site about Australian Road Fatalities

  Input a temperature as a floating point

Your program should input a temperature as a floating point number with an appended unit letter. It should then print the temperature in all four of the units above

  Write a program that reads the name of a data file

Write a program that reads the name of a data file which contains student ids (such as c1234500) and their scores. The program will find and print the average score, the number of students processed.

  Cleint software so that it does not display

Rewrite the cleint software so that it does not display an echo of a message sent by the users. Maybe it means that each time a user tries to send a private message that same message is also sent back to them? summary: stop that from happening?

  Implement the ransac algorithm for linear regression

You must find the observed data, threshold, also the outliers and remove them from (X,y) How exactly do i do this? please provide the code.

  Create a python function called sumofodds which takes one

Create a Python function called sumOfOdds which takes one argument, an integer greater thanor equal to 1, and returns the result of adding the odd integers between 1 and the value of thegiven argument (inclusive).

  Generate a random ordered list of integers

In Python, the use the binary search functions given(recursive and iterative). Generate a random ordered list of integers and do a benchmark analysis.

  Display the count of the groups and final balance

Using the For.. loop, Write a program to ask the user for 7 deposits. As the user enters a deposit amount, update the balance using accumulation concept.

  Write a program to determine the coefficients of expanded

Write a program to determine the coefficients of expanded form of (aX+bY+c)n. Every line in bold is questions to ask whoever runs the program to enter values or commands (y or n) at the console.

  Create a dictionary from the boys txt file

Create a dictionary from the boys.txt file that uses the boys' names as the key and the number of boys that were named that name as the value.

  Write python code to implement a basic number guessing game

CSIS1101- Write Python code to implement a basic number guessing game. The program will choose a random number between 1 and 9 (inclusive) using randint() .

  Write programs that read a sequence of integer inputs

Write programs that read a sequence of integer inputs and print The smallest and largest of the inputs. The number of even and odd inputs.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd