1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MAXImum [283]
3 years ago
4

Write a program to do the following. Ask the user to enter a string. Convert all letters to uppercase. Count and display the fre

quency of each letter in the string. For example, suppose the user enters the string "Csc.565", the program should display the following output because the letter C appears twice while the letter S appears once:

Computers and Technology
1 answer:
klasskru [66]3 years ago
8 0

Answer:

#section 1

strr=input("Enter a String: ")

allF = {}

strr= strr.upper()

#section 2

for char in strr:

   if char.isalpha():

       if char in allF:

           allF[char] += 1

       else:

           allF[char] = 1

#section 3

a =allF.items()

for key, val in a:

   print(f'{key}  {val}')

Explanation:

#section 1:

prompts the user to enter a string, converts the string to uppercase using the <em>upper()  </em>method and also initializes a dictionary that will be used to sore the each letter and how many time they occur.

i.e. Key(alphabet) : Value(occurrence)

#section 2:

we filter away all none alphabets like numbers and special characters with the<em> isalpha()</em> method, the FOR loop iterates through every character in the string.

if char in allF:

           allF[char] += 1

       else:

           allF[char] = 1

This block of code is responsible  for checking if a character has been stored in the dictionary if it is there it adds to the count in the character  Value in the dictionary  if otherwise(else) it adds to the character to the Key and gives the Value a count of 1.

#section 3:

The items() method returns a view object containing the key-value pairs of the dictionary, as tuples in a list. This allows us to use the for loop to iterate over each pair of Key, Value. and f-string allows us to print the key and value separately and just be more flexible with our output.

check attachment to see implementation of code.

You might be interested in
Why might a business professional choose to use a desktop computer rather than a tablet or laptop at work?
lawyer [7]
<h2>Laptops and Tablets are cool, classic, and have a business-y  vibe to them but Destop Computers are preferred because they're way more adaptable, have a lot of useful ports USB, SD, etc, and computer monitor vary a lot and anytime you want you can get one with lot's of RAM and Memory so that's very cool, and convenient of you're a businessman.</h2><h2>So what would I choose? I would probably choose A Laptop, but you know, it's business. :)</h2><h3>Good Luck on your Studies!</h3><h3>David Edward.</h3>
5 0
3 years ago
Read 2 more answers
Save As .csv .html Worksheet tab Format Cells SUM Function Destination cell Home tab AutoFit A. Applies a border or shading to s
stiv31 [10]

Answer and Explanation:

A.) Format Cells

When the format cells in an Excel then, change an appearance of the number without the changing a number itself. Apply the number formats (0.7, $0.70, 70%, etc) or other formatting (alignments, fonts, borders, etc).

1. Enter a value 0.7 into the cell B2.

By default, the Excel use the General formats (no specific numbers format) for the numbers To apply the number format, use a 'Format Cell' dialog box.  

2. Then, Select the cell B2.

3. Then, Right click, then click the Format Cell (or press the shortcut key CTRL + 1).

The 'Format Cell' dialog box will appears.

4. Then, For example, if you want - select Currency.

Note: The Excel give you the life preview of how a number will formatted.

5. After that, Click OK.

The Cell B2 will still contain the number 0.7. Then you only changed an appearance of the number. Most frequently used a formatting command that are available on Home tab.

6. On Home tab, in a Number group, click percentage symbol to apply the Percentage formats.

7. On Home tab, in Alignment group, center a numbers.

8. On Home tab, in Font group, add the outside border and change the fonts color to the blue.

B). Destination cell

Destination area or Destination cell - A range of the cells that is select to hold a summarized data in the consolidations. The destination area or cell can be on same worksheets as source data or on the different worksheets. Worksheet can contains only the one consolidation.

C). Save As

If you want to save workbook with the different name use File then click on Save As dialog box or use a shortcut key (Alt + F2).

Then, Select a folder that you wants to store a workbook in using Save in the drop-down lists.

Then, Enters a new filename in the File name box at bottom.

D.) .html

Extension of the web page workbooks is .html.

E). SUM

The SUM function is the built in function in the excel which is used to add all the numbers in the range of the cells and returns its result.

F). Home Tab

A clipboard group is on far left side of a Home Tab. It is an often used in the conjunctions with Editing group, which is on far right side of the tab.

G.) .csv

CSV stands for Comma Separated Value.

CSV is the simple file format that is used to store a tabular datas, such as the spreadsheet or the database. A File in the CSV formats can be imported and exported from the programs that stores data in the tables, such as the Microsoft Excel or the OpenOffice Calc.

H). Worksheet tab

.

To Show the Sheet tabs settings is turned off.

Firstly, ensure that Show Sheet tab is enabled or not.

To do, all the other Excel version, click the File >then Options >then Advanced, in the under Display option for the workbook, then ensures that there is the check in a Show sheet tabs box.

I). AutoFit

J). Sum, Product, Power, Sqrt, Quotient, Mod and many others.

There are 300+ formulas in Excel.

5 0
3 years ago
Suppose that you are asked to modify the Stack class to add a new operation max() that returns the current maximum of the stack
Advocard [28]

Answer:

Following are the code to the given points:

Explanation:

For point 8.1:

public String max()//defining a method max

{

   String maxVal=null;//defining a string variable that holds a value

   for(int x=0;x<n;x++)

   {

       if(maxVal==null || a[i].compareTo(maxVal)>0)//defining if blok to comare the value

       {

           maxVal=a[i];//holding value in maxVal variable

       }

   }

   return maxVal;//return maxVal variable value

}

For point 8.2:

public void push(String item)//defining a method push that accepts item value in a parameter

{

       a[n]=item;//defining an array to hold item value

       if(n==0 || item.compareTo(maxVals[n-1])>0)//use if to comare item value

       {

               maxVals[n]=item;//holding item value in maxVals variable

       }

       else

       {

               maxVals[n]=maxVals[n-1];//decreasing the maxVals value

       }

       n++;//incrementing n value

}

public String pop()//defining a method pop

{

       return a[--n];//use return value

}

public String max()//defining a method max

{

       return maxVals[n-1];//return max value

}

  • In the first point, the max method is declared that compares the string and returns its max value.
  • In the second point, the push, pop, and max method are declared that works with their respective names like insert, remove and find max and after that, they return its value.
7 0
3 years ago
Guys please inbox me​
ololo11 [35]

Answer:

how do i do that?

Explanation:

5 0
3 years ago
Read 2 more answers
Game Design Help please
valina [46]
This game on cool math
4 0
4 years ago
Other questions:
  • Which statements about Excel's FV function are correct?
    13·1 answer
  • Si la velocidad del sonido en el aire es de 330m/s , calcula la longitud De onda en metros, de una nota musical de frecuencia 55
    5·1 answer
  • ¿Por qué es importante generar proyectos innovadores?
    8·1 answer
  • What is an optimal Huffman code for the following set of frequencies, based on the first 8 Fibonacci numbers?
    8·1 answer
  • Imagine you had a learning problem with an instance space of points on the plane and a target function that you knew took the fo
    11·1 answer
  • Every modern nation has a Central Bank. Which of the following is the Central Bank for these United States?
    14·2 answers
  • Focusing on a target market makes it harder to develop products and services that specific groups of customers want.
    10·1 answer
  • Which of the following are considerations in e-commerce and e-government Internet sites? Check all of the boxes that apply.
    10·1 answer
  • What are some examples of duties Information Support and Service workers perform?
    7·2 answers
  • Versiones del Moodle
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!