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
Write a program that has the user input how many classes they are taking this semester and then output how many hours they will
NeTakaya

wait i don't understand: "Write a program that has the user input how many classes they are taking this semester and then output how many hours they will need to study each week."

8 0
3 years ago
Read 2 more answers
Eric would like to have a color textbook that makes it look as if the character in an image is speaking. Which object should he
timurjin [86]

Explanation:

the answer is call out safe or picture

3 0
4 years ago
1. I write about my travel experiences on my own personal ____?
alekssr [168]

Answer:

Hello There!!

Explanation:

1.blog

2.laptop

hope this helps,have a great day!!

~Pinky~

4 0
3 years ago
Demand is created through meeting customer buying criteria, credit terms, awareness (promotion) and accessibility (distribution)
tankabanditka [31]

Answer:

Bell

Explanation:

In the given case the product that has the highest Dec. Cust. Survey score will be treated as most competitive at the end of last year. Based on the information provided in the "Top Products in Thrift Segment" table, we can conclude that Bell has highest score for Dec. Cust. Survey score which stands at 31.

Please see attachment for the product list we referenced to as non was given.

7 0
3 years ago
1 what elements of composition are under your control in photoshop
inn [45]
Tone
Sharpness
Scale
Arrangement
7 0
3 years ago
Other questions:
  • Janet is testing the effectiveness of four different plant foods. She plants four identical seeds in four identical pots, supply
    6·2 answers
  • Business Risks are ​
    15·1 answer
  • Why are computer messages encapsulated?
    13·1 answer
  • A patient presents at an outpatient urgent care facility with an acute illness and is seen by a provider. A detailed history wit
    13·1 answer
  • When someone registers a domain name that is a company's trademark, hoping to resell it to the company at an exorbitant profit,
    14·2 answers
  • If the variable letter has been defined as a char variable, which of the following are not valid assignment statements to assign
    8·1 answer
  • A company that manufactures machine parts orders a new system that makes products at ten times the speed of the earlier machine.
    15·1 answer
  • Which of the following is NOT one of the four benefits of using email?
    14·1 answer
  • A merchant bank and a merchant have been involved in a Web-based electronic transaction. Which of the following mediates between
    9·1 answer
  • Does anyone have any tips on how to begin a 10 page Capstone project paper? I've got to write a write a research paper on the ty
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!