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
Ymorist [56]
3 years ago
9

Please convert this for loop into while loop

Computers and Technology
1 answer:
spayn [35]3 years ago
3 0

Answer:

The code segment was written in Python Programming Language;

The while loop equivalent is as follows:

i = 1

j = 1

while i < 6:

     while j < i + 1:

           print('*',end='')

           j = j + 1

     i = i + 1

     print()

Explanation:

(See attachment for proper format of the program)

In the given lines of code to while loop, the iterating variables i and j were initialised to i;

So, the equivalent program segment (in while loop) must also start by initialising both variables to 1;

i = 1

j = 1

The range of the outer iteration is, i = 1 to 6

The equivalent of this (using while loop) is

while ( i < 6)

Not to forget that variable i has been initialized to 1.

The range of the inner iteration is, j = 1 to i + 1;

The equivalent of this (using while loop) is

while ( j < i + 1)

Also, not to forget that variable j has been initialized to 1.

The two iteration is then followed by a print statement; print('*',end='')

After the print statement has been executed, the inner loop must be close (thus was done by the statement on line 6, j = j + 1)

As seen in the for loop statements, the outer loop was closed immediately after the inner loop;

The same is done in the while loop statement (on line 7)

The closure of the inner loop is followed by another print statement on line 7 (i = i + 1)

Both loops were followed by a print statement on line 8.

The output of both program is

*

*

*

*

*

You might be interested in
What are the 4 types of satellite?​
swat32

✨ Yøur answer in thé, Attachment ✨

5 0
3 years ago
Read 2 more answers
Technician A says that a camshaft must open and close each valve at exactly the right time relative to piston position. Technici
morpeh [17]
On single and double overhead cam engines, the cams are driven by the crankshaft, via either a belt or chain called the timing belt or timing chain. These belts and chains need to be replaced or adjusted at regular intervals.
3 0
3 years ago
The first widely adopted windows product, ____, featured a standardized look and feel, similar to the one made popular by apple'
slega [8]
<span>The first widely adopted windows product, Windows 3, featured a standardized look and feel, similar to the one made popular by Apple's Macintosh computer .
</span>
Microsoft’s Windows operating system was first introduced in 1985, Windows 3 which was released in 1990 was the first version to see more widespread success, because it had the ability to run MS-DOS programmes in windows which brought multitasking in programming.


8 0
3 years ago
Write an interface, PointingDevice, containing: an abstract method, getXCoord that returns an int an abstract method, getYCoord
vaieri [72.5K]

Answer:

Following are the code in java language

abstract interface PointingDevice // interface  PointingDevice,

{

// abstract method getXCoord()

public abstract int getXCoord();

// abstract method getYCoord()

public abstract int getYCoord();    

// abstract method attentionRequired()

public abstract boolean attentionRequired();  

// abstract method setResolution( )

public abstract double setResolution(double a);  

}

Explanation:

In this code we have declared a abstract interface "PointingDevice" which contains the four abstract method getXCoord of type int , getYCoord() of type int , attentionRequired() of type boolean and setResolution() of type double .

These method have only declaration not definition any interface or class which inherit the inteface PointingDevice must define all these four method otherwise it also be abstract .

4 0
3 years ago
On the Visit screen, you will not see one of the following:
san4es73 [151]

Answer:

The answer is "Option b".

Explanation:

An access level denotes a set of data type permissions or restrictions, that reduces the access level, which is an effective way to reduce failure modes, debug time and system complexity. and other options are not correct, i.e. define as follows:

  • In option a, In some of the cases, the system provides security, which is responded by the server to check the Eligibility of user, that's why it is not correct.
  • In option c, The home address is always shown on the URL, that's why it is not correct.

8 0
4 years ago
Other questions:
  • You just realized the turn signal on your vehicle is broken,
    15·1 answer
  • Which of the following is where you can save, select a template, change document properties, and close or exit excel?
    8·1 answer
  • I WILL MARK THE BRAINIEST!!!!!!!!!!!!! 50 POINTS!!!!!!!
    5·2 answers
  • The picture that graphically represents the items you use in Windows is called a/an
    5·1 answer
  • Which entity might hire a Computer Systems Analyst to help it catch criminals?
    12·2 answers
  • How many passes will it take to find the 20 in this list? (python)
    11·2 answers
  • Match the data types to the types of value they are: Currency, Text, Date/time, and Name.
    11·1 answer
  • What would a programmer use to stop a while-looping sequence and return to the beginning of the statement?
    11·2 answers
  • Assume that the Vehicle class contains a virtual method named CalculateMaxSpeed(). Assume that both the MotorVehicle and Automob
    12·1 answer
  • State two differences between a mouse pointer and a mouse cursor​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!