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
yarga [219]
3 years ago
14

2. Create a file with the follow integer/string content and save it as fun.txt. 6 fun. 3 hello 10 <> 2 25 4 wow! Write an

interactive program called PrintStrings that: • Generates file name based on the file path entered by the user • Then read the file fun.txt and produce the following output on the console. fun.fun.fun.fun.fun.fun. hellohellohello <><><><><><><><><><> 2525 wow!wow!wow!wow! Notice that there is one line of output for each integer/string pair. The first line has 6 occurrences of "fun.", the second line has 3 occurrences of "hello", the third line has 10 occurrences of "<>", the fourth line has 2 occurrences of "25" the fifth line has 4 occurrences of "wow!". Notice that there are no extra spaces included in the output. You are to exactly reproduce the format of this sample output. You may assume that the input values always come in pairs with an integer followed by a String (which could be numeric, such as "25" above).

Computers and Technology
1 answer:
Nesterboy [21]3 years ago
8 0

Answer:

see explaination

Explanation:

I made use of python program to solve this.

text file name with fun.txt.

6 fun. 3 hello 10 <> 2 25 4 wow!

Program code:

import re

file = open('fun.txt','r') #for reading file

strings="" #declaring empty string

for k in file:

strings=strings+k #all character in file is storing in strings variable for do operations

pattern = '\s' #for pattern \s is for space

result = re.split(pattern, strings) #split the string with space

for k in range(len(result)): #loop through the list of string

if(k%2) == 0: #checking for integer to time of string

p=int(result[k])

print(result[k+1] *p) #print times of the string(k+1)

Check attachment for output

You might be interested in
Write a program that prompts the user for their quarterly water bill for the last four quarters. The program should find and out
Fed [463]

Answer:

total = 0

for i in range(4):

   bill = float(input("Enter bill for quarter " + str(i+1) + ": "))

   total += bill

average = total / (4 * 3)

if average > 75:

   print("Average monthly bill is $" + str(average) + ". Too much water is being used")

if 25 <= average < 75:

   print("Average monthly bill is $" + str(average) + ". A typical amount of water is being used")

if average < 25:

   print("Average monthly bill is $" + str(average) + ". Thank you for conserving water")

Explanation:

*The code is in Python.

Create a for loop that asks the user to enter the bill for 4 quarters and calculate the total of the bills

Calculate the average monthly bill, divide the total by 12

Check the average for the given conditions. Depending on its value print the required message along with the average monthly bill

4 0
3 years ago
You order a new personal computer. A representative from the store calls to ask if you need CD-copying software in your personal
VashaNatasha [74]

Answer:

A.

Explanation:

The purpose of a CD-copying software is that it records data on a recordable CD.

7 0
3 years ago
Differentiate between tabular and column form layout​
NeTakaya

In tabular form the data is displayed in a table layout following a continuous series of records. In this almost all the records are displayed in a single layout. While in columnar form the data is displayed one record at a time.

6 0
2 years ago
RAM IS often referred
miss Akunina [59]
3

thank me later :))))))))
7 0
3 years ago
Capacity requirements are computed by multiplying the number of units scheduled for production at a work center by the:
podryga [215]

Answer:

.

Explanation:

5 0
3 years ago
Other questions:
  • Anti-bullying laws in most states are designed to provide
    14·2 answers
  • Brainly wont show me the "I'm Done" button after an interactive ad, and I cant figure out why. I've watched the entire ad, click
    11·2 answers
  • ____ is the official web portal for the U.S. government, providing access to all official U.S. government services and informati
    12·1 answer
  • PMI is a: computer program used to help managers write mission statements. rule of thumb used to determine how many employees sh
    15·1 answer
  • Implement function bin2dec that takes a binary number bin_num as a string argument and prints out the corresponding decimal numb
    9·1 answer
  • Define<br>output<br>devices<br>.<br>Give<br>any<br>three<br>examples<br>.<br>3.​
    8·2 answers
  • I wrote a program to calculate how many unique students I have taught over the years. It will read in a file formatted with firs
    5·1 answer
  • Explain the following terms <br><br>copyleft:<br><br>creative Commons:<br><br>GNU/GPL:​
    8·1 answer
  • Help plz, u just gotta select all that apply :)
    15·1 answer
  • Explains why we use tables in documents; and is at least three sentences long in word office 360​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!