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
Sergeu [11.5K]
3 years ago
7

Design the logic for a program that outputs every number from 1 through 15.

Computers and Technology
2 answers:
ankoles [38]3 years ago
3 0
Not sure what programming language, but i'll use Java

print (1)
print (2)
print (3)
print (4)
print (5)
print (6)
print (7)
print (8)
print (9)
print (10)
print (11)
print (12)
print (13)
print (14)
print (15)
Liula [17]3 years ago
3 0
Another way to think about this is through the use of a loop, since printing a number is a very repetitive task, you could also use,

number = 1
while number < 16:
      print(number)
      number = number + 1

The logic behind this is the "while" loop would check whether the variable 'number' is less than 16 (i.e. between 1 and 15) if so, it prints the number and then adds one to it. It then repeats the check over and over until 16 is reached and then the program terminates.
You might be interested in
The function below takes two arguments: a dictionary of strings (keys) to integers (values) a_dict and a list of strings key_lis
vitfil [10]

Answer:

  1. def getData(a_dict, key_list):
  2.    result = []
  3.    for key in key_list:
  4.        result.append(a_dict[key])
  5.    
  6.    return result  
  7. result = getData( {"puffin": 5, "corgi": 2, "three": 3} , ["three", "corgi"])
  8. print(result)

Explanation:

Let's define a function <em>getData() </em>with two parameters,<em> a_dict </em>and <em>key_list</em> as required by the question (Line 1).

Since the function is to return a list of associated values of dictionaries, a new list,<em> result</em>,  is declared and initialized with empty values (Line 2).

Next, use for-loop to traverse through every string in the input <em>key_list </em>(Line 4) and use the traversed key to address the value in the<em> a_dict </em>and add it to the <em>result</em> list (Line 5)

At last, return the <em>result </em>list as output (Line 7)

We can test the function using the test case from the question and we shall see the output as follows:

[3, 2]

8 0
3 years ago
Modify your previous exercise to determine if the user can ride a rollercoaster. To ride the rollercoaster, you must be at least
sweet-ann [11.9K]

Answer:

In Python:

age = int(input("How old are you? "))

height = float(input("How tall are you (inches)? "))

if age>=9 and height >= 42:

    print("You can ride the roller coaster")

else:

    print("You ca'nt ride the roller coaster")

Explanation:

The code segment of the "previous exercise" is not given; so, I rewrite the program from scratch using python.

And using the solution I provided, you'll have an idea of how to write the expected code If the "previous exercise" is not written in python,

This line prompts user for age

age = int(input("How old are you? "))

This line prompts user for height

height = float(input("How tall are you (inches)? "))

This checks if user is at least 9 years old and at least 42 inches tall

if age>=9 and height >= 42:

If true, the user gets to ride the roller coaster

    print("You can ride the roller coaster")

else:

If otherwise, the user will not ride the roller coaster

    print("You ca'nt ride the roller coaster")

4 0
3 years ago
These are Spealized graphics programs gor editing or modifying digital photographs
lisov135 [29]
They fall under the category of “Photo Editing Software” or “Image Manipulation Software”
8 0
3 years ago
What number system is the basis for all of the powerful computers and electronic devices in the world?
labwork [276]

Answer:

Binary

Explanation:

3 0
3 years ago
Which tab should gemima use to open the formula dialog box
mamaluj [8]

Answer:

you shouldn't being using this site to cheat on your test its supposed to help you study and understand how to do it

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • BI is an umbrella term that combines architectures, tools, databases, analytical tools, applications, and methodologies. b. BI i
    10·1 answer
  • Where can I watch infinity war for free?
    9·1 answer
  • When RadioButton objects are contained in a group box, the user can select only one of the radio buttons on the panel.
    12·1 answer
  • Telepresence provides the opportunity for people to work from home and attend virtually. True False
    5·2 answers
  • ​When preparing a representative sample from a list of 200 customers who complained about errors in their statements, a _____ co
    7·1 answer
  • Gleick believes that the book is
    8·1 answer
  • Generally speaking, problems are rarely caused by motherboards. However, there are some instances in which a motherboard can fai
    12·1 answer
  • What is the classification of the Gartner company?
    9·1 answer
  • HELP!!! What would var d=?
    7·1 answer
  • A friend wants to design an app but has never done so before and isn't sure how to begin. What would you suggest they do first?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!