File Letter Counter Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program.

Answers

Answer 1
Answer:

Answer:

The solution code is written in Python.

  1. fileName = input("Enter file name: ")
  2. target = input("Enter target character: ")
  3. with open(fileName, "r")as reader:
  4.    content = reader.read()
  5.    print(content.count(target))

Explanation:

Firstly, use input() function to prompt user for a file name. (Line 1)

Next, we use input() function again to prompt user input a target character (Line 2)

Create a reader object and user read() method to copy entire texts from to the variable content (Line 4 - 5).

At last we can get the number of times the specified character appears in the file using the Python string built-in method count() (Line 6)


Related Questions

Write a java program that use multiple arrays This is a simple array program which does not use an "external class & demo program" If you wish, you may break it down into methods, but that is not required. a. Set up 4 arrays which hold data about 6 items you want to sell: [make them up] int[ ] itemnum int[ ] quantity double[ ] price double[ ] sales b. Set up loops to load the itemnum, quantity and price arrays c. Set up another loop to calculate values for the sales array. [= price * quantity] d. Set up another loop to print the item number and sales amount for each transaction . e. Set up another loop to calculate the total sales of all 6 items f. print the total sales amount
Checkpoint 10.43 Write an interface named Nameable that specifies the following methods: _______{ public void setName(String n) public String getName()} Fill in the blank.
Factory Design Pattern Assignment This assignment will give you practice in using the Factory/Abstract Factory Design Pattern. You are going to create a Terraforming program. What does terraform mean
The following JavaScript program is supposed to print: 1 by 4 by 9on a single line by itself. Unfortunately the program contains at least eight mistakes. Write the corrected line beside the line in error.var N; // TextN := 1;document.writeln( N );document.writeln( “ by “);document.writeln( “N + 3”);document.writeln( “ by “ );document.writeln( N + 5);
In the Properties dialog box for each folder, the top pane shows the: groups or users with permission to access the folder. groups or users that do not have permission to access the folder:______ A. Degree to which each user or group may interact with the folder and its contents. B. Degree to which each user or group may interact with other users.

write a program that calculates the average of a group of 5 testscores, where the lowest score in the group is dropped. it shoulduse the following functionsa. void getscore() should ask the use for the test score, store itin a reference parameter variable and validate it. this functionshould be called by main once for each ofthe five score to be entered.

Answers

C++ program for calculating the average of scores

#include <iostream>

using namespace std;

const int n=5;//As per question only 5 test scores were there

int numbers[5];

void getscore(int i)//defining function for taking input

{

cin >> numbers[i];

while(numbers[i]<0 || numbers[i]>100)//score should be between 0 to 100

{

cout<<"\nThe number should be between 0 to 100\n";

cin>>numbers[i];

}

}

int main()//driver function

{

cout << "Enter 5 scores:\n";

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

{

getscore (i);//calling function each time for input

}

int s = 101;

double avg = 0;

for (int i = 0; i < n; i++)//loop for finding the smallest

{

s = numbers[i] < s ? numbers[i] : s;

}

for (int i = 0; i < n; i++) //loop for finding the Average

{

avg += numbers[i];

}

avg -= s;

avg /= 4;

cout << "Average of the four scores are: " << avg<< endl;//printing the output

return 0;

}

Output

Enter 5 scores:

4

5

6

7

8

Average of the four scores are: 6.5

Which of the following are common problems experienced with software applications? (choose all that apply)faulty microprocessor

missing DLL files

installation issues

configuration issues

applications running slowly

kernel panic

power cords not being plugged in

Answers

The common problems experienced with software applications will be missing DLL files, installation issues, configuration issues, applications running slowly, and kernel panic. Then the correct options are B, C, D, E, and F.

What are the common problems experienced with software applications?

Today's world depends heavily on technology. Technology now controls not just how businesses run but also how quickly many different sectors across the world are developing. The pace of technical development dictates the rate of development and company growth, leaving human progress and economic expansion at the whim of technology.

Some of the common problems are as follows:

  • Missing DLL files
  • Installation issues
  • Configuration issues
  • Applications running slowly
  • Kernel panic

The normal issues experienced with programming applications will be missing DLL documents, establishment issues, arrangement issues, applications running gradually, and part alarms. Then the right choices are B, C, D, E, and F.

More about the common problems with software applications link is given below.

brainly.com/question/29704760

#SPJ12

Answer:

All but the top and bottom on edge 2020

Explanation:

Write an algorithm that gets as input your current credit card balance, the total dollar amount of new purchases, and the total dollar amount of all payments. The algorithm computes the new balance, which this time includes an 8% interest charge on any unpaid balance below $100 , 12% interest on any unpaid balance between $100 and $500, inclusive, and 16% on any unpaid balance about $500.

Answers

Answer:

balance = float(input("Enter the current credit card balance: "))

purchases = float(input("Enter the amount of new purchases: "))

payments = float(input("Enter the amount of all payments: "))

unpaid = purchases - payments

if unpaid >= 0 and unpaid < 100:

   balance = balance + payments - purchases - (unpaid * 0.08)

elif unpaid >= 100 and unpaid <= 500:

   balance = balance + payments - purchases - (unpaid * 0.12)

else:

   balance = balance + payments - purchases - (unpaid * 0.16)

   

print("The balance is " + str(balance))

Explanation:

*The code is in Python.

Ask the user to enter the balance, amount of purchases, and amount of payments

Calculate the unpaid balance, subtract payments from purchases

Check the unpaid balance. If it is smaller than 100, calculate the new balance, add payments, subtract purchases and the 8% interest of unpaid balance. If it is between 100 and 500, calculate the new balance, add payments, subtract purchases and the 12% interest of unpaid balance. If it is greater than 500, calculate the new balance, add payments, subtract purchases and the 16% interest of unpaid balance

Print the balance

Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as input the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is

Answers

Answer:

The height of the ball after t seconds is h + vt - 16t 2 feet:

def main():

getInput()

def getInput():

h = int(input("Enter the initial height of the ball: ")) # Adding the int keyword before input() function

v = int(input("Enter the initial velocity of the ball: ")) # Same as above

isValid(h,v)

def isValid(h,v):

if ((h <= 0) or (v <= 0)):

print("Please enter positive values")

getInput()

else:

maxHeight(h,v)

def maxHeight(h,v):

t = (v/32)

maxH = (h + (v*h) - (16*t*t))

print ("\nMax Height of the Ball is: " + str(maxH) + " feet")

ballTime(h, v)

def ballTime(h,v):

t = 0

ballHeight = (h + (v*t) - (16*t*t))

while (ballHeight >= 0):

t += 0.1

ballHeight = (h + (v*t) - (16*t*t))

print ("\nThe ball will hit the ground approximately after " + str(t) + " seconds")

# Driver Code

main()

Answer:

I am writing a python code.

def getInput():

   h = int(input("enter the height: "))

   v = int(input("enter the velocity: "))

   isValid(h,v)    

def isValid(h,v):

   if (h<= 0 or v<=0):

       print("not positive ")            

   else:

       height = maximumHeight(h,v)

       print("maximum height of the ball is", height," ft.")

       balltime = ground_time(h,v)

       print("The ball will hit the ground after", balltime, "s approximately.")

def maximumHeight(h,v):

   t = (v/32)

   maxheight = (h + (v*t) - (16*t*t))

   return maxheight    

def ground_time(h,v):

   t = 0.1

   while(True):

       heightofball = (h + (v*t) - (16*t*t))

       if (heightofball <= 0):

           break

       else:

           t += 0.1  

   return t

Explanation:

There are four functions in this program.

getInput() function is used to take input from the user which is height and velocity. h holds  the value of height and v holds the value of velocity. input() function is used to accept values from the user.

isValid() function is called after the user enters the value of height and velocity. This function first checks if the value of height and velocity is less than 0. If it is true the message not positive is displayed. If its false then maximumHeight() is called which returns the maximum height of the ball and function ground_time() is called to return the time when the ball will hit the ground.

maximumHeight() function first divides the value of velocity with 32 as the ball will reach its maximum  height after v/32 seconds. It then returns the maximum height by using the formula:  heightofball = (h + (v*t) - (16*t*t)).

ground_time() calculates the time the ball takes to reach the ground. There is a while loop to height after every 0.1 second and determine when the height is no longer a positive. It uses (h + (v*t) - (16*t*t)) formula to calculate the height and when the value of height gets less than or equal to 0 the loop terminates otherwise it keeps calculating the height while adding 1 to the value of t at each iteration. After the loop breaks, it returns the value of t.

To see the output of the maximum height and time taken by ball to reach the ground, you can call the getInput() function at the end of the above program as:

getInput()

Output:

enter the height: 9

enter the velocity: 10

maximum height of the ball is 10.6525  ft.

the ball will hit the ground after 1.2 s approximately.

98 POINTS HELP ASAP PLEASE!!!!You have been asked to create a program for an online store that sells their items in bundles of five. Select the appropriate code that would display how many bundles are available for sale.

A.print(5 // totalItems)
B.print(totalItems // 5)
C.print(totalItems(5) )
D.print(5(totalitems) )

Answers

B. Print(totalitems // 5)

Answer:

B. Print Totalltems // 5

Explanation:

Well, if you learn how to create bundles on Amazon, you can eliminate the competition, set your price, and offer customers a product they’ll absolutely love.

Describe what happens at every step of our network model, when a node on one network establishes a TCP connection with a node on another network. You can assume that the two networks are both connected to the same router.Your submission must include a detailed explanation of the following:

Physical layer

Data link layer

Network layer

Transport layer

MAC address

IP address

TCP port

Checksum check

Routing table

TTL

Answers

TCP (Transmission control protocol) makes sure  that  all data packets transferred by (IP)internet protocol  arrives safely.
This is what happens  when a node of one network establishes aTCP connection with a node on another network:
1.Physical layer.
It  is the lowest layer which defines how the cables,network cards,wireless transmitters and other hardware connect computers to the networks and the networks to the rest of  the internet.example of  physical layer is Ethernet,WIFI e.t.c.
It provides the means to transfer the actual bits from one computer to another.In an Ethernet network a computer is connected by plugging a network cable in its Ethernet  card and then plugging the other end of that cable into a router or switch.
It specifies how bits of data are sent over that cable.
2. Data link layer
The data link layer provides a network connection between hosts on a particular local network.
The internet protocol basically assumes all computers are part of one very large "web" of nodes that can all pass packets to other nodes.there is always route from one node to another,even if sometimes a very large number of intermediate nodes get involved. The data link layer makes this assumption true.
For example the client runs on a personal computer in someones home network which is set up using Ethernet protocol .The data link layer now is that Ethernet protocal. The IP packets that this computer transmits are added as payload to Ethernet packets that are transmitted over the local network to ADSL(Asymmetric digital subscriber line) modem that connects the local network to the provider.
3.Network layer
The network layer is responsible for transmitting and routing data packets over the network.The internet uses the internet protocal (IP) as its network layer.Each node on the network has an addres which is called the ip address of which data is sent as IP packets.
when the client sends its TCP connection request, the network layer puts the request in a number of packets and transmits each of them to the server.each packet can take different route and some packets may get lost along the way.If they all make it the transport layer at the server is able to reconstruct the request and it will prepare response confirming that the TCP connection has been set up.
This response is sent back again in a number of IP packets that will hopefully make it to the client.
4. Transport layer
This layer is realized by two protocals. The first is transmission control protocal(TCP) and the second one is the user datagram protocol(UDP) they both break up a message that an application wants to send into packets to the intended recipient.
At the recipients side,both take the payload from the recieved packets and pass those to the application layer.
Again taking an example of email, the email client and server communicate over a reliable TCP connection.The server listens on a certain port untill a connection request arrives from the client .The server acknowledges the request and aTCP connection is established.Using this connection the client and server can exchange data.
5.MAC address
MAC addres(media access control layer) This  layer is responsible for moving data packets to and from one network interface card (NIC) to another accross shared channel.
6. IP address
IP ( internet protocol) it is the the principal protocol in the internet protocol suite for relaying data-grams across network boundaries. its routing function enables inter-networking and essentially establishes the internet.
The  IP is responsible for the following:
i) IP addressing 
ii)host-to-host communications.
iii)fragmentation
7. TCP port
This is an endpoint to a logical connection and a the way a client program specifies a specific server program on a computer in a network.The port number identifies what type of port it is.
8.Checksum check
Checksum is a small sized datum derived from a digital data for the purpose of detecting errors which may have been introduced during its transmission or storage.
Checksum is a simple type of reduduncy check that is used to detect errors in data.
checksum is created by culculating the binary values in a packet or other block of data using some algorithm and storing the results with the data.
9.Routing table
Routing table is a data table stored in a router or a networked computer that lists the routes to particular network destinations and some cases metrics(distances) associated with those routes.
10. TTL
TTL Time-to-live is an internet protocal that tells a network router whether or not the packet has been in the network too long and should be discarded in IPV6.the TTL in each packet has been renamed (hop) limit.
Hop is one portion of the path between source and destination .Data pass through bridges,routers and gateways as they travel between source and destination.each time packets are passed to the  next network device,a hop occurs.





 





Answer:

Your submission must include a detailed explanation of the following:

Physical layer

Physical layer refers, in computing, to the consideration of the hardware components involved in a given process. In terms of networks, the physical layer refers to the means of connection through which data will travel, such as serial interfaces, or coaxial cables.

Data link layer

The data link layer is the protocol layer in a program that handles the moving of data into and out of a physical link in a network. The data link layer is Layer 2 in the Open Systems Interconnection (OSI) architecture model for a set of telecommunication protocols. Data bits are encoded, decoded and organized in the data link layer, before they are transported as frames between two adjacent nodes on the same LAN or WAN. The data link layer also determines how devices recover from collisions that may occur when nodes attempt to send frames at the same time.

Network layer

The network layer of the OSI model is responsible for controlling overall network operation. Its main functions are the routing of packets between source and destination, even if they have to pass through several intermediate nodes along the route, congestion control and accounting for the number of packets or bytes used by the user for charging purposes.

Transport layer

The transport layer is the layer in the open system interconnection (OSI) model responsible for end-to-end communication over a network. It provides logical communication between application processes running on different hosts within a layered architecture of protocols and other network components.   The transport layer is also responsible for the management of error correction, providing quality and reliability to the end user. This layer enables the host to send and receive error corrected data, packets or messages over a network and is the network component that allows multiplexing.

MAC address

When we talk about physical address we are referring to the MAC (Media Access Control) address which is 48 bits (12 hexadecimal characters).

IP address

An Internet Protocol Address (IP Address) is a numeric label assigned to each device (computer, printer, smartphone, etc.) connected to a computer network using the Internet Protocol. for communication.

TCP port

if you are using a File Transfer Protocol (FTP) program, the Internet connection is made through TCP port 21, which is a standard port for this protocol. If you are downloading files from BitTorrent, one of the ports ranging from 6881 to 6889 will be used for such activity.

Checksum check

This is done by calculating the checksum of the data before sending or storing it, and recalculating it upon receipt or retrieval from storage. If the value obtained is the same, the information has not changed and therefore is not corrupted.

More simplified forms of these sums are vulnerable because they do not detect some forms of failure. The simple sum of character values, for example, is vulnerable to their changing order by the commutativity of the sum. There are more elaborate ways of calculating these sums that solve these problems, such as the Cyclic Redundancy Check or CRC widely used for fault detection by dividing polynomials.

Routing table

In a computer network, a routing table, or routing information base, is a data table stored on a network router or host that lists the routes to specific network destinations and, in some cases, metrics associated with those routes.

TTL

Time to Live, which means the number of hops between machines that packets can take a computer network before being discarded (maximum of 255).

Any router is programmed to discount a unit of TTL to packets flowing through it. This is a way to avoid that packages remain on the net for infinite time, if the routing is not being done properly, as in the case of looping.

This value is also useful in screening circuits traversed by packets, as does the tracerouting tool.

Hope this helps :) -Mark Brainiest Please :)