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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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