answer.
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
Lostsunrise [7]
2 years ago
15

Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o

f a search range. The file should be read using the file.readlines() method. The input file contains a list of alphabetical, ten-letter strings, each on a separate line. Your program should output all strings from the list that are within that range (inclusive of the bounds).
Computers and Technology
2 answers:
inna [77]2 years ago
6 0

Answer:

filepath = 'Iliad.txt'

start = 'sometxtstart'

end = 'sometxtend'

apending = False

out = ""

with open(filepath) as fp:

   line = fp.readline()

   while line:

       txt = line.strip()

       if(txt == end):

           apending = False

       if(apending):

           out+=txt + '\n'

       if(txt == start):

           apending = True                

       line = fp.readline()

print(out)

xenn [34]2 years ago
3 0

Answer:

def func(filename, lower, upper):

   file = open(filename, 'r').readlines()

   for i in range(int(lower), int(upper)):

       print(file[i].rstrip())

func('strings','2','4')

Explanation:

file is provided below, name: strings in text format

appleelppa

banananana

cattaccatt

dogdogdogd

elephanttn

froggorffr

goattaoggo

horseesroh

illiterate

jumppmujju

You might be interested in
The function below takes a single string parameter: sentence. Complete the function to return everything but the middle 10 chara
dolphi86 [110]

Answer:

def get_middle_ten(sentence):

   ind = (len(sentence) - 12) // 2

   return sentence[ind:ind + 12]

# Testing the function here. ignore/remove the code below if not required

print(get_middle_twelve("abcdefghijkl"))

print(get_middle_twelve("abcdefghijklmnopqr"))

print(get_middle_twelve("abcdefghijklmnopqrst"))

7 0
2 years ago
Create an application named TestSoccerPlayer that instantiates and displays a SoccerPlayer object. The SoccerPlayer class contai
frutty [35]

Answer:

public class TestSoccerPlayer {

   public static void main(String[] args) {

       SoccerPlayer playerOne = new SoccerPlayer("Rinco",9,16,22);

       System.out.println("The player of the season is "+playerOne.getName()+" His Jessey Number is "+playerOne.getJerseyNum()

       +" In the 2019/2020 season he scored and total of "+playerOne.getGoalsScored()+" and "+

               playerOne.getAssists()+" Asists");

   }

}

See the SoccerPlayer class with the feilds and methods (constructor, getter and setters) in the explanation section

Explanation:

public class SoccerPlayer {

   private String name;

   private int jerseyNum;

   private int goalsScored;

   private int assists;

   public SoccerPlayer(String name, int jerseyNum, int goalsScored, int assists) {

       this.name = name;

       this.jerseyNum = jerseyNum;

       this.goalsScored = goalsScored;

       this.assists = assists;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public int getJerseyNum() {

       return jerseyNum;

   }

   public void setJerseyNum(int jerseyNum) {

       this.jerseyNum = jerseyNum;

   }

   public int getGoalsScored() {

       return goalsScored;

   }

   public void setGoalsScored(int goalsScored) {

       this.goalsScored = goalsScored;

   }

   public int getAssists() {

       return assists;

   }

   public void setAssists(int assists) {

       this.assists = assists;

   }

}

5 0
2 years ago
Ld' is the instruction with the longest latency on the CPU from Section 4.4 (in RISC-V text). If we modified ld and sd so that t
antiseptic1488 [7]

Answer:

See explaination

Explanation:

a)

The primary factors that influence the program's speed on a new CPU are given as:-

CPU Clock speed where the speed of the process instructions is being measured.

Multi-core which is when the transistors work faster than respective CPU.

Cache which helps to note that the transition of data is smooth and fast.

b)

So, there are two CPUs suppose the old one as 'A' and the modified one as 'B'.

'A' has following features---

It takes more time to execute program as it has more clock cycle time or we can say it has low clocking rate or low speed in terms of MHz or GHz. Clock rate is the inverse of Clock Cycle Time. When you will increase the clocking rate of CPU, it will get faster and then Clock Cycle Time will get reduced.

It has less instructions provided.

'B' has following features----

It takes less time to execute program as it has less clock cycle time or we can say it has high clocking rate or high speed in terms of MHz or GHz.

It has more instructions provided.

The performance of CPU depends upon 2 factors:

The number and types of instructions that are executed by the CPU

How fast the CPU can execute those instructions?

So, overall CPU B is better as it has less execution time than CPU A but the performance will always depend upon the number and type of instructions executed by the CPU so it may vary.

Please refer to attachment for instructions and formulas.

8 0
2 years ago
Mary is employed by a multinational firm, and works long hours on a desktop computer. Recently, she experienced back pain and vi
siniylev [52]
D. Avoiding sitting helps relieve stress made in the spine
4 0
2 years ago
Read 2 more answers
Assume we have a computer where the clocks per instruction (CPI) is 1.0 when all memory accesses hit in the cache. The only data
umka21 [38]

Answer:

6.6 times faster considering I-cache

Explanation:

<em>Given data </em>:

CPI  = 1

Data accesses ( loads and stores ) = 40% of instructions

Miss penalty = 200 clock cycles

Miss rate = 2% for I-cache ,  5% for D-cache

<u>Determine how much faster the computer will be if all instructions were Cache hits </u>

In this condition the memory stall = 0

hence: CPU ideal time = ( Ic * CP1  + memory stall ) * clock cycle time --- ( 1 )

                                     = ( Ic * 1 + 0 ) * clock cycle time

<em>Note : Memory stall = Ic * ( 1 + load fraction ) * miss rate * miss penalty  --- ( 2)</em>

back to equation 1

Memory stall ( for I-cache ) = Ic * ( 1 + 40% ) * 2% * 200

                                              = 5.6 Ic

Input value into equation 1

CPU ideal time = Ic * 1 + 5.6Ic * clock cycle time

                         = ( 6.6 Ic ) * clock cycle time

To determine how much faster we take the ratio of the CPU ideal time

=   6.6 Ic * clock cycle time / 1  Ic * clock cycle time

= 6.6 times faster

4 0
2 years ago
Other questions:
  • What are the set of rules to move data from one computer to another?
    11·1 answer
  • Danilo is planning the art to include in a business proposal his team is preparing. For which of the following items should Dani
    7·2 answers
  • Assume that myCar is an instance of the Car class and that the Car class has a member function named accelerate. Which of the fo
    7·1 answer
  • Write a function so that the main program below can be replaced by the simpler code that calls function mph_and_minutes_to_miles
    5·1 answer
  • What is the name of the program file that you can enter in the Windows search or Run box to execute Event Viewer? What process i
    12·1 answer
  • How long does it take 2 consultants to create a slide deck of 120 slides, assuming one consultant make 2 slides per hour?
    8·1 answer
  • Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar tha
    6·1 answer
  • Consider the following two code segments, which are both intended to determine the longest of the three strings "pea", "pear", a
    7·1 answer
  • Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invo
    8·1 answer
  • Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount. Each parameter is of type int. The fu
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!