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
In Java, it is possible to create an infinite loop out of while and do loops, but not for-loops. true or false
soldier1979 [14.2K]

Answer:

False is the correct answer for the above question.

Explanation:

  • In java programming language or any other programming language, any loop can be infinite.
  • It is because the infinite loop is called for that loop which is not run in a finite number of times.
  • The loop is used to repeat some lines in a finite number of times. Any loop has three things- first is the initial value which tells the loop to start, The second is the condition check which states when the loop will stop and the third is an operation which directs some variable, so that the condition may be false after some finite amount of time.
  • If the condition will not false in any iteration of the loop, then the loop can proceed for an infinite amount of time.
  • The above-question states that the while loop and do while loop can be infinite which is a true statement.
  • But it also states that the 'for' loop can not be infinite which is not a correct statement which is described above. Hence false is the correct answer to the above question.
8 0
3 years ago
How do you render and export files on blender
Debora [2.8K]

Answer:

Save your Blender file (. blend) in the same folder as your . obj file, if you didn't already.

Click on File/External Data/Pack All into . blend.

Click on File/External Data/Unpack All Into Files.

Choose "Use files in current directory (create when necessary)"

Explanation:

<em>Hope </em><em>it </em><em>helps </em><em>ya </em><em>ItzAlex</em>

6 0
3 years ago
What computer company was founded in 1975?
erica [24]
Microsoft company was founded in 1975
6 0
3 years ago
What is the importance of using the proper markup language?
Klio2033 [76]

the answer is D. without the right tags the content wont be accurately indexed

3 0
3 years ago
Read 2 more answers
Do people answer questions more on this site or be on social more ??? no right or wrong answer your opinion
Sindrei [870]
It really depends on the person
3 0
3 years ago
Other questions:
  • Suppose a computer can execute 1 billion instructions/sec and that a system call takes 1000 instructions, including the trap and
    10·1 answer
  • WILL UPVOTE ALL.
    7·1 answer
  • How do you delete text from a slide
    14·2 answers
  • The ash and dust from a volcanic eruption can cause a _______ change in the environment.
    13·1 answer
  • Which of the following is a beneficial reason to extract mineral resources from the earth?
    13·2 answers
  • Signing up for a(n) ____ will automatically provide you with web content that is updated on a regular basis.
    15·1 answer
  • Multiple client switches and routers have been set up at a small military base. The network team decided to implement Terminal A
    15·1 answer
  • Hi everyone,
    6·1 answer
  • Two time series techniques that are appropriate when the data display a strong upward or downward trend are ___________ and ____
    14·1 answer
  • We can create tables in MS. Word from *<br> 2 points<br> Insert Tab<br> Home Tab<br> Mailings Tab
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!