Calculate the number of occurrences of each letter

Assignment Help Python Programming
Reference no: EM132360816

Programming Problems:

1. a) Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. It should not modify the original list.

b) From part (a) you have a function named has_duplicates that takes
a list as a parameter and returns True if there is any object that appears more than once__ in the list. Use a dictionary to write a faster, simpler version of has_duplicates.

2. Download the file "GA.txt" and save it into your Python34 directory.

a) Write a program that will process the text file (open ('GA.txt')) to calculate the number of occurrences of each letter of the alphabet contained in the file. You should convert the file to all lower case letters. (I removed punctuation for you!) Your program should display the results.

b) After you have calculated the number of occurrences, you should calculate the relative frequency of each letter, and display the results.

Save a copy of this program for yourself, and for homework, get the display to be in alphabetical order! You may have time to do it now,but probably not (typing errors waste time).

Hints: you may use the string methods:

s.lower() to convert a string to lower case s.strip() to remove spaces

Note: I already removed the punctuation and new lines , but for your information, the string class can remove all of that for you:
import string

s.strip(string.punctuation) removes any punctuation marks

s.strip(string.whitespace) removes tabs, new lines, etc.

Reference no: EM132360816

Questions Cloud

Written scripts in database from one environments : Compared and written scripts in database from one environments to other.Develop test strategy, test cases and test suites based on wireframes and defined system
Prepare a preliminary business report for the ceo : MPM701 – Business Process Management - Deakin University - prepare a preliminary business report for the CEO. The main body of your report must be structured
Create a class named animal thatis used to store information : InfoTc 1040 Introduction to Problem Solving and Programming Animal Class -Create a class named Animal thatis used to store information about an animal.
Department of labor occupational network : A role in which you are interested, and research that role within the U.S. Department of Labor's Occupational Network, also known as O*NET.
Calculate the number of occurrences of each letter : Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once.
Service reduces risk for commercial enterprises : How business process as a service (BPaaS) reduces risk for commercial enterprises.
What ares some ways organizations : Organizations must find ways to guard against project failures. What ares some ways organizations can put in these safeguards?
Live memory images and images of various forms off media : Go online and research some tools that would be valuable in collecting both live memory images and images of various forms off media.
Case study in the library focusing on disaster recovery : Find a case study in the library focusing on Disaster Recovery. Please discuss the incident that occurred and steps the organization took to address the issue.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a program to receive a series of numbers

Write a program to receive a series of numbers (including decimal) from the user until enter key is pressed. Process the input data and display number count, sum and average. Use proper data type and format.

  Basic simulation model to simulate tumour growth

Question: Come out with a basic simulation model to simulate tumour growth which follows the paper CPM and LGCA

  Program that allows user to do basic trigonometry functions

You need to create a program that allows the user to do basic trigonometry functions. First, ask the user if he or she would like to do sine, cosine, or tangent.

  Write a python program that generates an informative website

ICT112 - University of Sunshine Coast - Generated Web Site for Aussie Road Fatalities - write a Python program that generates an informative web site

  Write a program to calculate the sum of three given numbers

Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.

  Print out the average score accurate to two decimal places

print out the average score accurate to two decimal places.

  Construct function that will evaluate arithmetic expression

Construct a python function named calc that will evaluate a simple arithmetic expression. The input to your program will be a string of the form.

  What relationships and properties do you need to model

Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard - What relationships and properties

  Write the statement needed to find out how many prime number

Assume a variable n has been associated with positive integer. Write the statements needed to find out how many prime numbers.

  Write python program isosceles tri equilateral tri rectangle

Write python program Isosceles Tri Equilateral Tri Rectangle, Write another "driver" script called project1.py which imports the polygon.py module, reads an input file of polygonal data and writes another file of areas and perimeters.

  Write a program to compute distance from current position

Write a program to compute the distance from current position after a sequence of movement and original point. Then just print the nearest integer.

  Write a method that interprets the length of a time

Write a method that interprets the length of a Time as the number of seconds that have elapsed from midnight to the that time.

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