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]
2 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]2 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
Changes in computer technology have an effect on _____.
dlinn [17]

Answer: Changes in computer technology have an effect on everyone.

6 0
3 years ago
Out-of-order instruction execution can cause problems because a later instruction may depend on the results from an earlier inst
scoundrel [369]

Answer:

C

Explanation:

6 0
2 years ago
PLEASE HELP WITH MY CODING!!!!!!!!!!!!!!
igor_vitrenko [27]
A: Similar..............
6 0
3 years ago
Read 2 more answers
How to make logo black and white in paint?
Pie
Change the color to black and white
7 0
3 years ago
The part of the poppet valve that contacts the valve seat is called the?
Amiraneli [1.4K]
C. is the correct answer
6 0
3 years ago
Read 2 more answers
Other questions:
  • SELECT vendor_name, COUNT(*) AS number_of_invoices, MAX(invoice_total - payment_total - credit_total) AS balance_due FROM vendor
    15·1 answer
  • 1. In the.js file, write the JavaScript code for this application. Within the click event handlers for the elements in the sideb
    14·1 answer
  • Storing a value in a variable<br> Exponent<br> Variable<br> Assignment<br> Operator
    13·1 answer
  • What may happen if there is too much harmony in a design?
    14·1 answer
  • When should students practice netiquette in an online course?
    9·1 answer
  • The memory unit of a computer has 2M Words of 32 bits (or 4 bytes) each. The computer has an instruction format with 4 fields: a
    14·1 answer
  • Which of the following activities does an effective team do?
    15·2 answers
  • Question #1 Mutiple Select Which features are important when you plan a program? Select 4 options. Knowing what you want the pro
    5·1 answer
  • Question 1 of 10
    12·1 answer
  • Which one of these are a valid IPv4 address?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!