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
lana [24]
3 years ago
7

write a program to input 3 numbers and print the largest and the smallest number without using if else statement​

Computers and Technology
1 answer:
klemol [59]3 years ago
8 0

Answer:

def main():

   # input

   num1 = int(input("Type in a number: "))

   num2 = int(input("Type in another number: "))

   num3 = int(input("Type in another number: "))

   list1 = [num1, num2, num3]

   # sorts the array

   list1.sort()

   # list1[-1] prints the first element in the array

   print("The largest number is: " + str(list1[-1]))

   # -len(list1) takes the length of the list, in this case 3, and makes it a negative number.  

   # That negative number is then used as an index for the list1 array in order to print the lowest number.

   print("The smallest number is: " + str(list1[-len(list1)]))

main()

Explanation:

Hope this helped :) I left some comments so you know what's going on. You can also use max(list1) and min(list1) but I chose indexing because indexing is the better way of doing stuff like this.

Have a good day!

You might be interested in
Why is monitoring email, voice mail, and computer files considered legal?
Sati [7]

Explanation:

Monitoring someone's emails,voice mails and computer files is considered is illegal because you are accessing someone's personal information which is not regarded as  ethical .

There are certain reasons where one's email,voice mails and computer files can be monitored are as following:

  1. Protect the security information and security.
  2. Investigation of complaints of harassment.
  3. Preventing personal use of employer's facilities.
6 0
3 years ago
The owner of a candle shop has asked for your help. The shop sells three types of candles as shown below:
Keith_Richards [23]

Answer:

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {

   double total = 0;

   double fPrice, sPrice, tPrice;

   int firstN = 0, secdN = 0, thirdN = 0, fTime, sTime, tTime;

   int totalT = 0;

   isEnd = "n";

   for (;;){

       if (isEnd == "y"){

           break;

       }

       Scanner in = new Scanner(System.in);

       int option = in.nextInt();

       switch (option){

         case 1:

             fPrice = 2.50;

             fTime = 5;

             System.out.print("Enter number of items: ");

             firstN += in.nextInt();

             totalT += fTime * firstN;

             total += fPrice * firstN;

             break,

         case 2:

             sPrice = 3.75;

             sTime = 7;

             System.out.print("Enter number of items: ");

             secdN += in.nextInt();

             totalT += sTime * secdN;

             total += sPrice * secdN;

             break,

         case 3:

             tPrice = 5.99;

             tTime = 12;

             System.out.print("Enter number of items: ");

             thirdN += in.nextInt();

             totalT += tTime * thirdN ;

             total += tPrice * thirdN;

             break,

        default:

             System.out.println("Looking forward to the Weekend");

       }

       System.out.print("Do you want to end the order? y/n: ");

       isEnd = in.nextLine();

   }

   System.out.println("Number of Type 1 candles bought : "+firstN);

   System.out.println("Number of Type 2 candles bought : "+secdN);

   System.out.println("Number of Type 3 candles bought : "+thirdN);

   System.out.println("Total cost is : "+total);

   System.out.println("Total burn time is : "+totalT);

   double costPerBurn = (totatT * 60) / total;

   System.out.println("Cost per minute : "+ costPerBurn);

 }

}

Explanation:

The Java program creates a continuous for-loop statement that gets the candle type, price and amount ordered from a switch and accumulates the total cost and burn time of the candles bought and the cost per minute burn of the candles consecutively.

3 0
3 years ago
On the 74ls74 d flip-flop, the clk input has a small triangle. the pr (preset) and clr (clear) inputs have a circle. what do the
topjm [15]
The triangle indicates that the clock signal is an edge-triggered signal.
The circle indicates that the signal is low-active (ie., inverted).
The 74LS74 has a positive-edge trigger clock (low to high).
7 0
4 years ago
When you align or size a group of selected controls, the changes are made relative to the
babunello [35]

Answer:

The primary control.

When you align or size a group of selected controls, the changes are made relative to the primary control.

Explanation:

When selected controls are set together, apart from the primary control, to be executed, they take preeminence over the established primary controls.

3 0
3 years ago
. A search engine is a way to
Sindrei [870]
<span>Option A, the search engine is the way to get information on the internet through a web browser, installed on an operating system of a computer. It is software that gathers all the information and stores it to accelerate the search for the users by entering the data of the desired information.</span>
8 0
4 years ago
Read 2 more answers
Other questions:
  • Why is Bot_Seth Trash at video games?
    13·2 answers
  • How do i stream from my chromebook to my tv?
    8·1 answer
  • Which statements are true about modern
    9·1 answer
  • What is the output?
    12·1 answer
  • select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
    7·1 answer
  • PLEASE HELP ASAP
    15·1 answer
  • Information that's been collected to help solve a problem is called
    10·1 answer
  • Need help with Python coding from Zybooks...
    9·1 answer
  • What is a cell? how is it referred?​
    8·1 answer
  • Which communication technology often takes the place of printed interoffice communication?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!