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]
3 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]3 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
Which of the following is not a shared characteristic of new media.
tensa zangetsu [6.8K]
The last one , info is not sparse or little , we have plenty of it
6 0
3 years ago
What will be the results of executing the following statements? x.setEditable(true); x.setText("Tiny Tim"); a. The text field x
maxonik [38]

Answer:

Option B: The text field x will have the value "Tiny Tim" and the user will be able to change its value.

Explanation:

  • The first statement say:  x.setEditable(true);

It will only change the property of the text present in x to editable. This means that whenever the text value needs to change the user can edit it.

  • The second statement say:   x.setText("Tiny Tim");

It will put the text "Tiny Tim" into the attribute x and present it as the output or result.

6 0
3 years ago
________ are the most popular method used by visitors to find web sites.
Inessa05 [86]
Search engines, such as Google and DuckDuckGo, <span>are the most popular method used by visitors to find web sites.</span>
3 0
3 years ago
Need the answer ASAP plz !!!!!
Evgesh-ka [11]
Performance would be the answer
3 0
3 years ago
What should not be compromised when trying to meet standards and deadlines?
n200080 [17]
A i believe is the answer
5 0
3 years ago
Other questions:
  • While interoperability and unrestricted connectivity is an important trend in networking, the reality is that many diverse syste
    12·1 answer
  • Which software application offers a variety of templates for creating reports, flyers, and newsletters that you can access withi
    7·1 answer
  • Mac and PC .Which one is better for professional users, and why
    6·1 answer
  • 3. When you right-click a linked spreadsheet object, what commands do you choose to activate the Excel features?
    7·2 answers
  • Hi need help on this <br> what is cyberspace
    14·1 answer
  • True/False: On the piano, middle C is located to the left of the 2 black keys in the middle.
    9·2 answers
  • Please help with this coding question
    8·2 answers
  • Look at the code in the example below, and then answer the question.
    9·1 answer
  • Which of the examples is part client side code
    10·1 answer
  • imagine that you are explaining the art of visual comparison to a group of photography students. You are mentoring. What do you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!