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
Reil [10]
2 years ago
12

Write and test a Python program to find and print the smallest number in a set of integer numbers. The program should read input

numbers until it reads a negative number. The negative number serves as a sentinel or marker telling the program when to stop reading numbers. The smallest of all numbers input as well as how many numbers were read (not considering the sentinel number) should be printed.
Computers and Technology
1 answer:
NikAS [45]2 years ago
6 0

Answer:

numbers = []

count = 0

while True:

   number = int(input("Enter a number: "))

   if number < 0:

       break

   else:

       numbers.append(number)

       count += 1

min_number = min(numbers)  

print(str(min_number) + " was the smallest among " + str(count) + " entered numbers.")

Explanation:

Initialize an empty array, to hold the entered numbers, and count as 0

Create a while loop that iterates until a specific condition is met

Inside the loop, ask the user to enter the numbers. When the user enters a negative number terminate the loop. Otherwise, add the entered number to the numbers array and increment the count by 1.

When the loop is done, find the smallest of the number in the numbers array using min method and assign it to the min_number.

Print the min_number and count

You might be interested in
What is the major benefit Smartphones and tablet computers have had on social media?
Naddika [18.5K]

Answer:

c

Explanation:

The biggest advantage of smartphones and tablets is that they increased the mobility. This allowed users to access the social media platforms whenever they want. The users can login to their accounts even they are travelling by bus or walking around. This was not possible back in the days where people mostly use desktop computers.

8 0
2 years ago
Help me asap ill give brainliest
kobusy [5.1K]

Answer:

Give me brainliest thanks

6 0
3 years ago
1)Which of the following statements about the print statement are TRUE? (Check all that apply)
balu736 [363]

Answer:

1) C

5) D

6) A

Explanation:

3 0
3 years ago
This question involves the implementation of the PasswordGenerator class, which generates strings containing initial passwords f
liq [111]

The following code will be used for the PasswordGenerator class.

<u>Explanation:</u>

import java.util.Random;

public class PasswordGenerator {

   private static int passwordsGenerated =0;

   private static Random random = new Random();

   private String prefix;

   private int length;

   public PasswordGenerator(int length,String prefix) {

       this.prefix = prefix;

       this.length = length;

   }

   public PasswordGenerator(int length) {

       this.prefix = "A";

       this.length = length;

   }

   public String pwGen(){

       String pwd= this.prefix+".";

       for(int i=1;i<=this.length;i++){

           pwd+=random.nextInt(10);

       }

       passwordsGenerated+=1;

       return pwd;

   }

   public int pwCount(){

       return passwordsGenerated;

   }

   public static void main(String[] args) {

       PasswordGenerator pw1 = new PasswordGenerator(4,"chs");

       System.out.println(pw1.pwCount());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwCount());

       PasswordGenerator pw2 = new PasswordGenerator(6);

       System.out.println(pw2.pwCount());

       System.out.println(pw2.pwGen());

       System.out.println(pw2.pwCount());

       System.out.println(pw1.pwCount());

   }

}

8 0
2 years ago
Which page layout is most commonly used for a website with a large navigation menu?
mestny [16]

Explanation:

The Name is called, (navigation menu..)

to direct users 2 info., they look up...

7 0
2 years ago
Other questions:
  • Running the cpu at a faster speed than the manufacturer recommends is called ________.
    11·1 answer
  • Which situation can result in positive population growth?
    14·1 answer
  • After reviewing the various types of network connections available, a client chooses a network connection that is considered to
    13·1 answer
  • What's the difference between intranet and extranet ​
    9·1 answer
  • What connectionless protocols are implemented at the lower layers of the OSI model, what is usually used to acknowledge that the
    5·2 answers
  • Where do you place the logical test argument in an JF function formula?
    5·2 answers
  • A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static Ar
    14·1 answer
  • What is it called when an attacker convinces you to enter personal information at an imposter website after receiving an email f
    10·2 answers
  • What is ambiguous grammar, explain in maximum 50words.
    5·1 answer
  • 5. Give one word answers:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!