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
Temka [501]
4 years ago
13

Write a program that prints all the numbers from 0 to 6 except 3 and 6. Expected output: 0 1 2 4 5

Computers and Technology
1 answer:
stellarik [79]4 years ago
8 0
<h2>Answer:</h2><h2></h2>

for x in range(7):

   if (x == 3 or x==6):

       continue

   print(x, end=' ')

print("\n")

<h2>Output:</h2>

>> 0 1 2 4 5

<h2>Explanation:</h2><h2></h2>

The code above has been written in Python. The following explains each line of the code.

<em>Line 1:</em> for x in range(7):

The built-in function <em>range(7)</em>  generates integers between 0 and 7. 0 is included but not 7. i.e 0 - 6.

The for loop then iterates over the sequence of number being generated by the range() function. At each iteration, the value of x equals the number at that iteration. i.e

For the first iteration, x = 0

For the second iteration, x = 1

For the third iteration, x = 2 and so on up to x = 6 (since the last number, 7, is not included).

<em>Line 2:</em> if (x == 3 or x == 6):

This line checks for the value of x at each iteration. if the value of x is 3 or 6, then the next line, line 3 is executed.

<em>Line 3:</em> continue

The <em>continue</em> keyword is used to skip an iteration in a loop. In other words, when the continue statement is encountered in a loop, the loop skips to the next iteration without executing expressions that follow the <em>continue</em> statement in that iteration. In this case, the <em>print(x, end=' ')  </em>in line 4 will not be executed when x is 3 or 6. That means 3 and 6 will not be printed.

<em>Line 4:</em> print(x, end=' ')

This line prints the value of x at each iteration(loop) and then followed by a single space. i.e 0 1 2 ... will be printed. Bear in mind that 3 and 6 will not be printed though.

<em>Line 5:</em> print("\n")

This line will be printed after the loop has finished execution. This line prints a new line character.

You might be interested in
Lol WAKE UP!!! and get ready to answer my questions.
deff fn [24]

Answer:

<h2>1. Variable Creation Statement</h2><h2>2. Fav_Num=7</h2>

Explanation:

<h2><em>Hope This Helps :)</em></h2><h2>Im not sure if the 2nd one is correct but i think that it is.</h2>
5 0
3 years ago
Floating point numbers?
blondinia [14]

Answer:

Thank you so much!!!

God bless you!!!

You the best!!!

Explanation:

4 0
3 years ago
Which statement are true regarding mainframe computers
Dominik [7]

what are the answer choices?

5 0
4 years ago
The ________ contains the central electronic components of the computer. select one:
Sati [7]
The motherboard contains the central electronic components of the computer.
6 0
3 years ago
Select one among the the main categories of computer software, which one is not a category
kakasveta [241]

Answer:

utilities

Explanation:

the other 3 are Cs programs

7 0
3 years ago
Other questions:
  • R15. Suppose there are three routers between a source host and a destination host. Ignoring fragmentation, an IP datagram sent f
    8·1 answer
  • What is the name of the computer through which e-mail messages are sent and received?
    12·1 answer
  • What is the minimum internal temperature that the chicken must reach?
    11·1 answer
  • How do unstar another user
    14·1 answer
  • Universal Container sales reps can modify fields on an opportunity until it is closed. Only the sales operations team can modify
    13·1 answer
  • You have heard that it is possible to improve your computer's performance by storing all related files for a particular program
    9·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    7·1 answer
  • Write a C++ program that reads a temperature value and the letter C for Celsius or F for Fahrenheit. Print whether water is liqu
    14·1 answer
  • I am fast when im thin, I'm slow when im thick.<br><br>Air is my weakness,<br><br><br>What am I?
    13·1 answer
  • A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!