subject

ALIGNMENT: The purpose of this assignment is to provide practice with reading data from a text file and using lists and loops to iterate through the data. You may find string functions like .split(“,”) to be helpful in parsing out the data being read. ASSIGNMENT: Student body elections were recently held with the following candidates on the ballot (shown here in Python lists!):

presCandidates = ["Alex Abernathy", "Brooklyn Bianco"]
vpCandidates = ["Chris Cortez", "Darcy Delaney","Emery Evans"]
secCandidates = ["Pat Peters", "Robin Ramirez", "Sam Smith", "Tracy Turner"]

A programming student had the brilliant idea of writing a program for students to vote on a computer and store their choices in a test file, whose format is each line representing the president, vice president, secretary voted for as a comma-delimited string. The text file looks like that shown below (except there are over 300 lines):

Brooklyn Bianco, Darcy Delaney, Pat Peters
Alex Abernathy, Emery Evans, Sam Smith
Alex Abernathy, Emery Evans, Sam Smith
Brooklyn Bianco, Chris Cortez, Sam Smith
Brooklyn Bianco, Chris Cortez, Tracy Turner
Brooklyn Bianco, Chris Cortez, Pat Peters
Alex Abernathy, Chris Cortez, Pat Peters
Alex Abernathy, Darcy Delaney, Robin Ramirez
Brooklyn Bianco, Emery Evans, Tracy Turner
But the student can’t figure out how to read the data into a Python program and have it tally the ballot and display the results. Can you help the student? The election. txt data file is available in the Canvas Assignment for downloading.

Write an original Python program that reads the data file and presents the results and use “def” functions: Many ways to do this, but here is my approach: Read the data file one line at a time (.readline()) in a while loop. I’d recommend removing the “\n” character a the end of the read string, and then split it by the comma (lookup the .split( ) string method. Split puts the items into a list). Then compare the result list item to the candidates; names and increment the appropriate variables (or items in an integer list) to keep track of votes received by each candidate. In the output, show the votes cast for each candidate and the total votes cast:

05C screen shot

Specifications & Tips:

Save your file with as “CIS156_05C_Election Results_YourLastName. py”
Print the project tile on the first line. Print the next line showing your name as the developer, followed by a blank line (remember you can use \n). Then provide a description of what the program does.
You are limited to using features discussed thus far in class or in the assigned readings/videos to date. Thus you may not use custom classes to solve the problem, but loops, conditional structures, variables, lists, string methods and read/write methods can all be used in your code.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges"what's being bought" are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them"for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s . so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of events"s of length m and s of length n, each possibly containing an event more than once"and decides in time o(m + n) whether s is a subsequence of s.
Answers: 3
question
Computers and Technology, 22.06.2019 03:00
Data is processed, stored, and transmitted as a series of 1s and 0s. each 1 or 0 is called a(n) . a series of eight 0s and 1s, called a(n) , represents one character—a letter, number, or punctuation mark. data becomes when it is presented in a format that people can understand and use. digital signals are represented by two different , such as +5 volts and +.2 volts. digital data can also take the form of light and dark spots etched onto the surface of a cd or the positive and negative orientation of particles on the surface of a hard disk. data consists of numbers that might be used in arithmetic operations. it can be represented digitally using the number system. data is composed of letters, symbols, and numerals that are not used in arithmetic operations. computers represent this type of data using , ebcdic, unicode, or utf-8. data is quantified using terms such as or kibibyte (1024 bytes), and prefixes such as or mebi (1,048,576), and giga or (1,073,741,824). to reduce file size and transmission times, digital data can be compressed. compression provides the means to compress data and reconstitute it into its original state. compression throws away some of the original data during the compression process. compressed files usually have at the end of the file name and are represented with special icons. these files have to be or unzipped before you can view the data they contain.
Answers: 1
question
Computers and Technology, 22.06.2019 18:10
How can i delete permalinks from a word press site?
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
You know the right answer?
ALIGNMENT: The purpose of this assignment is to provide practice with reading data from a text file...
Questions
question
Business, 01.06.2020 03:58