Find Jobs
Hire Freelancers

python code

$10-30 USD

已完成
已发布超过 6 年前

$10-30 USD

货到付款
We like to process some voting data. a) Ask the user for the number of candidates in a local election. Use a try/except block to make sure the user does not enter a character or a floating point number as input. You need a loop to assure the user enters a valid whole number. b) Given the number of candidates, ask for the user for last names of a series of candidates and the number of votes received by each candidate and store the data in 2 parallel arrays. c) Validate the number of votes to make sure the number of votes is not a negative number. If a negative number is entered, the program must issue a message and continue to ask the user for a valid entry. d) Write a function to display each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. The percentage value is calculated by dividing the number of votes by the total number of votes and multiplying the number by 100. The function accepts 2 arrays and the size of the array and displays the desired output. Make sure to display the percentage values to 2 digits after the decimal point. e) Write a function that accepts the name of an output file and displays the array of names and the array of votes to the provided output file. Each record must be written on its own line. Note that the name of the file is entered in the main function and the value passed to the function along with the arrays to be displayed. f) Write a function to return the name of the winner. DO NOT use a pre-defined Python function. The function accepts the array of names and votes, finds the minimum number of votes and returns the name associated with the minimum number of votes. g) Write a function to return the name of the loser. DO NOT use a pre-defined Python function. The function accepts the array of names and votes, finds the maximum number of votes and returns the name associated with the minimum number of votes. h) Write a function to sort the candidates by name. I just need the names in a sorted order. The function accepts an array of names and sorts the data. After the function is called, the data would be in alphabetical order. LOOK at the end of this document for a pseudocode for a function that sorts the data. ALL you have to do is to convert the pseudocode to Python code. Make sure to display the data in the sorted order. i) Write a function that accepts as parameter the name of a candidate and return the number of votes received by the candidate. So, if the user enters Duck, the output will be 6000. Of course, if the given name does not exist, display an appropriate message. For a pseudocode of a simple sequential search algorithm, see the algorithm at the end of this document. Make sure the output is descriptive. The following is an example for a test run.
项目 ID: 15845426

关于此项目

3提案
远程项目
活跃6 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
i am a python expert and i can code it for you.
$30 USD 在1天之内
4.9 (124条评论)
6.0
6.0
3威客以平均价$25 USD来参与此工作竞价
用户头像
Hey I can do this. Please ping me with more details. Stay tuned, I'm still working on this proposal.
$20 USD 在1天之内
4.8 (3条评论)
3.0
3.0
用户头像
I have been working in python since last 2 years. experienced with different framework like django odoo and flask.
$25 USD 在2天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
Las Vegas, United States
5.0
1
付款方式已验证
会员自12月 11, 2017起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。