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
forsale [732]
3 years ago
6

In Python, what is returned when evaluating [n for n in range(10) if n % 2]?​

Computers and Technology
1 answer:
Firlakuza [10]3 years ago
8 0
First we need to understand what "n for n in range(10)" means. Basically, we are iterating through all the values n that are in the range of 10 (meaning 0, 1, 2, 3, ..., 9).

Next we are evaluating if n%2. The percentage sign is used to represent modulus which is the remainder of when two numbers are divided. In this case, we are dividing n by 2, and the remainder is our result. When dividing by 2, the only possible remainders are 0 or 1, which when used in an if statement represent the boolean vlaues false and true, respectively. We are doing this calculation for each n from 0 to 9, and if the result is true, we output n to an array.

The numbers that will result in true (a remainder of 1) are the odds numbers. For example, 4/2 = 2 with nothing left over while 5/2 = 2 with 1 left over.

So the following is returned:

[1, 3, 5, 7, 9]
You might be interested in
which of the following is something that an information systems (IS) professional would do? A. devise new ways to use computers
AlladinOne [14]

Answer:B

Explanation:

it professionals build and repair computers, create and aunts in networks, and help people with their technology needs.

5 0
3 years ago
Bianca is preparing special dishes for her daughter’s birthday. It takes her a minutes to prepare the first dish, and each follo
blagie [28]

Answer:

The solution code is written in Python:

  1. a = int(input("Input first dish time: "))
  2. b = int(input("Input extra minutes: "))
  3. t = int(input("Input time available: "))
  4. dishesCount = 1  
  5. currentTotal = a + b
  6. while(currentTotal <= t):
  7.    dishesCount += 1
  8.    currentTotal += currentTotal + b
  9. print("Number of dishes can be prepared: " + str(dishesCount))

Explanation:

Firstly, prompt user to input the first dish time, extra minutes and time available and assign the values to variable a, b and t, respectively (Line 1-3).

Next, create variable dishesCount to hold the number of dishes can be prepared (Line 5).

Get the current total time by adding a and b and assign it to variable currentTotal (Line 6).

While the currentTotal is less than or equal to t, increment the dishesCount by one and then add the hour of current dish to the currentTotal (Line 9-10).

At last, display the number of dishes that can be prepared in t minutes (Line 12).

4 0
4 years ago
What does the windows update feature allow you to do?
Mariulka [41]
The answer is D
Explanation: none
3 0
3 years ago
Read 2 more answers
Explain at least one reason why programming languages have functions
Salsk061 [2.6K]
With functions we can separate different parts of our code. each functions implements a single logical part of the program.

for example sqrt() function does square root. so we can use it in different programs, because it's a stand-alone component.

6 0
3 years ago
What do you click on to minimize all open windows? the Show Desktop icon the Start menu the system tray the taskbar
SOVA2 [1]

Answer:

The answer to this question can be given as "The show desktop icon".

Explanation:

To minimize all open windows we use to click on the Show Desktop icon. When we click on this desktop icon it automatically minimize all the open windows that are open on the computer screen. And all the option are not correct that can be described as:

The Start menu is part of the Microsoft windows. Start menu offers a central launching point for system programs and executing other tasks.

The system tray is part of the Window. It is on the Taskbar. It contains miniature icons for easy access to system functions.

That's why the correct answer is "The show desktop icon".

7 0
4 years ago
Read 2 more answers
Other questions:
  • The following code in a different program is not working properly. The message should display the value of the intCounter variab
    14·1 answer
  • What new information, strategies, or techniques have you learned that will increase your technology skills? Explain why its impo
    7·1 answer
  • Does any body like animal jam
    11·2 answers
  • What is the main role of LDAP?
    14·1 answer
  • How is the illusion of animation achieved using Sprites with multiple costumes?
    12·1 answer
  • Which of the following illustrations is depicted in the icon that's used to access Windows Help and Support files?
    13·1 answer
  • A company has a number of employees. The attributes of EMPLOYEE include Employee ID (identifier), Name, Address, and Birthdate.
    11·1 answer
  • Explain the relevancy of computers in today's global society​
    11·1 answer
  • Write a method named countInRange that accepts three parameters: an ArrayList of integers, a minimum and maximum integer, and re
    6·1 answer
  • Any movie/show suggestions??
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!