# Write a loop that counts the number of space characters in a string. Recall that the space character is represented as ' '.

I am writing Python program.

string = input("Enter a string: ")

print(string.count(' '))

Explanation:

The first statement takes input string from the user.

input() is used to read the input from the user.

The next statement uses count() function to count the number of times the specified object which is space ' ' hereoccurs in the string.

The print() function is used to return the number of times the space occurs in the string entered by the user.

Output:

Enter a string: How are you doing today?

4

The screenshot of program and its output is attached.

## Related Questions

Assume that two computers are directly connected by a very short link with a bandwidth of 125 Mbps. One computer sends a packet of 1000 Bytes to the other computer. What’s the end-to-end delay (ignoring the propagation delay)?

End to End Delay = 64 micro second

Explanation:

Given

Bandwidth = 125Mbps

A packet = 1000 bytes

Converting bandwidth from Mbps to bit/s

Bandwidth = 125* 10^6 bits/s

Bandwidth = 125,000,000 bit/s

End to End delay is calculated as

Length of Packet ÷ Bandwidth

Length of Packet = 1,000 byte --- convert to bits

Length of Packet = 1000 * 8

Length of Packet = 8,000 bits

So, End to End delay = 8,000/125,000,000

End to End Delay = 0.0000064 seconds --- convert to micro second

End to End Delay = 64 micro second

IN PYTHON Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value.

Ex: If the input is:

Enter the number of integers in your list: 5
Enter the 5 integers:
50
60
140
200
75
Enter the threshold value: 100
the output is:

The integers that are less than or equal to 100 are:
50
60
75

The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. Such functionality is common on sites like Amazon, where a user can filter results. Your code must define and call the following two functions: def get_user_values() def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold) Utilizing functions will help to make your main very clean and intuitive.

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

for value in user_values:

if value < upper_threshold:

print(value)

def get_user_values():

n = int(input())

lst = []

for i in range(n):

lst.append(int(input()))

return lst

if __name__ == '__main__':

userValues = get_user_values()

upperThreshold = int(input())

output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

Explanation:

For each of the following algorithms medicate their worst-case running time complexity using Big-Oh notation, and give a brief (3-4 sentences each) summary of the worst-case running time analysis. (a) Construction of a heap of size n , where the keys are not known in advance.
(b) Selection-sort on a sequence of size n.
(c) Merge-sort on a sequence of size n.
(d) Radix sort on a sequence of n integer keys, each in the range of[ 0, (n^3) -1]
(e) Find an element in a red-black tree that has n distinct keys.

Explanation:

(a) Construction of a heap of size n , where the keys are not known in advance.

Worst Case Time complexity - O(n log n)

Two procedures - build heap, heapify

Build_heap takes O(n) time and heapify takes O(log n) time. Every time when an element is inserted into the heap, it calls heapify procedure.

=> O(n log n)

(b) Selection-sort on a sequence of size n.

Worst Case Time complexity - O(n^2)

Selection sort finds smallest element in an array repeatedly. So in every iteration it picks the minimum element by comparing it with the other unsorted elements in the array.

=> O(n^2)

(c) Merge-sort on a sequence of size n.

Worst Case Time complexity - O(n log n)

Merge sort has two parts - divide and conquer. First the array is divided (takes O(1) time) into two halves and recursively each half is sorted (takes O(log n) time). Then both halves are combines (takes O(n) time).

=> O(n log n)

(d) Radix sort on a sequence of n integer keys, each in the range of[ 0 , (n^3) -1]

Worst Case Time complexity - O (n log b (a))

b - base of the number system, a - largest number in that range, n - elements in array

Radix sort is based on the number of digits present in an element of an array A. If it has 'd' digits, then it'll loop d times.

(e) Find an element in a red-black tree that has n distinct keys.

Worst Case Time complexity - O (log n)

Red-black tree is a self-balancing binary tree => The time taken to insert, delete, search an element in this tree will always be with respect to its height.

=> O(log n)

What is not an operating system

In the early days of computer technology, which system was justified because data-processing personnel were in short supply, hardware and software were expensive, and only large organizations could afford computers

Centralized Processing

Explanation:

Centralized processing was developed to process all of the data in a single computer, and since the first computers were stand-alone with all input and output devices in the same room, only the largest organizations could afford to use centralized processing.

Which of the following is NOT a typical action of the catch block?Select one:
a. Throwing the exception
b. Completely handling the exception
c. Rethrowing the same exception for the calling environment
d. Partially processing of the exception