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
What does "FDDI" stand for in Technology?
Komok [63]
Pretty sure it's Fiber Distributed Data Interface
6 0
3 years ago
Read 2 more answers
You support Richman Investments, a brokerage firm that employs 20 brokers. Each broker has his own client computer, and the firm
PSYCHO15rus [73]

Answer:

Test Windows update on one computer first.

Explanation:

To ensure that there are no usability issues, the Windows update services should be tested on one computer. This move is to check for any usability issues before the update is deployed to other computers. As soon as the usability is tested and confirmed on one computer after the update, the Windows update services can be used to deploy the updates to other computers.

4 0
3 years ago
which of the following commands can be used to display any email messages awaiting delivery alongside the reason that they were
Rasek [7]

The command that can be used to display any email messages awaiting delivery alongside the reason that they were not delivered is known as Mailq.

<h3>What is Email?</h3>

Email stands for Electronic mail. It may be defined as a type of method that significantly involves the exchange of computer-stored messages from one user to one or more recipients via the internet.

The command "Mailq" stands for mail queue. It is the command in Linux that prints the queued mail gain in form of sending it to the user. This command prints a list of messages that are in the mail queue. It is the same as the Sendmail-bp command.

Therefore, "mailq" is the command that can be used to display any email messages awaiting delivery alongside the reason that they were not delivered.

To learn more about Email, refer to the link:brainly.com/question/24688558

#SPJ1

6 0
1 year ago
Letter Frequency Write a function that will take a string and return a count of each letter in the string. For example, "my dog
Nostrana [21]

Answer:

Check the explanation

Explanation:

Code to copy:

// ConsoleApplication7.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include <iostream>

#include <cstring>

#include <string>

using namespace std;

int * letterFrequency(char s[]);

int main()

{

  int *freq_letters;

  char *s = new char[100];

  freq_letters = new int[26];

  //To read the input string in order to find the frequency of each letter

  cout << "Enter a string: ";

  cin.getline(s, ' ');

  //call the function to find the occurrence of each alphabet

  freq_letters = letterFrequency(s);

  //Display the count

  cout << "Letter Frequency " << endl;

  for (int i = 0; i < 26; i++)

  {

      //Constriant to check if the letter appeared at least once in the string and so printing the frequency of its occurence

      if (freq_letters[i] != 0)

      cout << " " << static_cast<char>(i + 'a') << " " << freq_letters[i] << endl;

  }

  system("pause");

  return 0;

}

//Define the function to find occurrence of each letter in the input string

int * letterFrequency(char s[])

{

  int *occurrence_array;

//to store the output of occurrences for each alphabet

  occurrence_array = new int[26];

// to store the count of occurrence for each letter temporarily

  int letter_count;

  // for loop to check the occurrence for all 26 alphabets

 

  for (int i = 0; i < 26; i++)

  {

      letter_count = 0;

      for (int j = 0; j < strlen(s); j++)

      {

          /*comparing the ascii values of each alphabet with every character from the string by converting it to lower case i.e. case insensitive*/

          if (int('a') + i == int(tolower(s[j])))

              letter_count++;

      }

      occurrence_array[i] = letter_count;//To store the count calculated for each alphabet

  }

  return occurrence_array;

}

The following below code screenshot and output shows that when the string is entered, the output will shows each lettercount irrespective of whether the letter is in capitals or small and does not count non-letter characters (i.e spaces, punctuations etc.)

6 0
3 years ago
When creating envelopes, how will you adjust the layout?
Burka [1]
It D because I hade this too so it is D
4 0
3 years ago
Read 2 more answers
Other questions:
  • Select the correct answer.
    6·1 answer
  • If we have a priority queue storing approximately million numbers, and the bottom level is "full", which of the following statem
    9·1 answer
  • When a computer is booted the checks the computer's components?
    7·1 answer
  • software that provides capabilities common across all organizations and industries is known as ________ software.
    15·2 answers
  • For enterprise servers, or servers accessed around the clock, SATA disks are preferred over SAS disks. True or False
    12·1 answer
  • Which of these is an example of collective voice?
    8·2 answers
  • The sun can be an excellent source of natural light.<br> True.<br> False.
    8·2 answers
  • Write a program to find the principle amount​
    10·1 answer
  • Consider our authentication protocol 4.0, in which Alice authenticates herself to Bob, which we saw works well (i.e., we found n
    15·1 answer
  • Which of the expressions is false? when a = 10 and b = 4
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!