answer.
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
White raven [17]
1 year ago
12

Compute the average of a list of user-entered integers representing rolls of two dice. The list ends when 0 is entered. Integers

must be in the range 2 to 12 (inclusive); integers outside the range don't contribute to the average. Output the average, and the number of valid and invalid integers (excluding the ending 0). If only 0 is entered, output 0. The output may be a floating-point value.Ex: If the user enters 8 12 13 0, the output is:Average: 10Valid: 2Invalid: 1Hints:
Computers and Technology
1 answer:
Leno4ka [110]1 year ago
6 0

Answer:

mylist = []

total = 0

valid = 0

invalid = 0

num = int(input("Number: "))

while num != 0:

    mylist.append(num)

    if(num>=2 and num<=12):

         total = total + num

         valid = valid + 1

    else:

         invalid = invalid + 1

    num = int(input("Number: "))

   

print("Average: "+str(total/valid))

print("Valid: "+str(valid))

print("Invalid: "+str(invalid))

   

Explanation:

The solution is implemented in Python

This line defines an empty list

mylist = []

The next three lines initializes total, valid input and input to 0 respectively

total = 0

valid = 0

invalid = 0

This line prompts user for input

num = int(input("Number: "))

This loop is repeated while input number is not 0

while num != 0:

This adds input number to the list

    mylist.append(num)

This checks for valid inputs

    if(num>=2 and num<=12):

If valid, the sum is calculated

<em>          total = total + num</em>

And the number of valid inputs is incremented by 1

<em>          valid = valid + 1</em>

If otherwise,

    else:

The number of invalid inputs is incremented by 1

         invalid = invalid + 1

This prompts user for another input

    num = int(input("Number: "))

   

This calculates and prints the average

print("Average: "+str(total/valid))

This prints the number of valid inputs

print("Valid: "+str(valid))

This prints the number of invalid inputs

print("Invalid: "+str(invalid))

You might be interested in
Consider the following method intended to modify the parameter names by removing all instances of the String n.
Anastasy [175]

Answer:

int i = 0; i < names.size(); i++

Explanation:

The ArrayList must be read in the forward direction, and it is going to start from 0 certainly. Also, the iteration is going to end when i is exactly one less than the size of the ArrayList. And this is possible only if we choose the option mentioned in the Answer section. In this, i starts from 0 and iterates till i is one less than name.size() which is the size of the ArrayList.

7 0
2 years ago
At which stage should James, a website designer, gather information about the website he wants to create, and at which stage sho
viva [34]
<h2>Answer: James should gather information in the <u><em>Learning</em></u> phase and begin the site’s coding in the <u><em>Development</em></u> phase.</h2>

8 0
2 years ago
Of 500 sessions that occurred on a website during a one-week period, 200 of them started on the homepage; 100 of these 200 sessi
Elena L [17]

Answer:

the homepage bounce rate

Explanation:

Bounce rate is defined as the percentage of people that visits a page on a website and then exit or leave. That is, the visitors did not view any other page except the first one and they just leave the page after that visit. In order to get the bounce rate, the total number of visitors to a single page is taken and its then divided by the total number of visits to the website. For example, if the total number of visitors to a website over a period of time is 3000, while those that only visited a page on the website is 500, then the bounce rate is

(500/3000) * 100 = 16%

For this question, the homepage recorded 100 visited only once out of 200 which means homepage bounce rate is 50% : (100/200)*100

While website bounce rate is total number of bounces across the website/total visit to the website

100+100 =200 this is the total bounces across the website

200/500 :500 is the total visit to the website

(200/500)*100 = 40 %

Therefore the homepage bounce rate is higher than the site bounce rate

7 0
2 years ago
Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a
Gnesinka [82]

Answer:

Explanation:

The following code is written in Java. It is hard to fully create the code without the rest of the needed code including the T class and the Measurable interface. Regardless the following code can be implemented if you have that code available.

 public static T minmax(ArrayList<T> mylist) {

       T min = new T();

       T max = new T();

       for (int x = 0; x < mylist.size(); x++) {

           if (mylist.get(x) > max) {

               max = mylist.get(x);

           } else if (mylist.get(x) < min) {

               min = mylist.get(x);

           }

       }

       

       return (min, max);

   }

5 0
2 years ago
An encryption system works by shifting the binary value for a letter one place to the left. "A" then becomes: 1 1 0 0 0 0 1 0 Th
Vika [28.1K]

Answer:

The hexadecimal equivalent of the encrypted A is C2

Explanation:

Given

Encrypted binary digit of A = 11000010

Required

Hexadecimal equivalent of the encrypted binary digit.

We start by grouping 11000010 in 4 bits

This is as follows;

1100 0010

The we write down the hexadecimal equivalent of each groupings

1100 is equivalent to 12 in hexadecimal

So, 1100 = 12 = C

0010 is represented by 2 in hexadecimal

So, 0010 = 2

Writing this result together; this gives

1100 0010 = C2

Going through the conversion process;

A is first converted to binary digits by shifting a point to the left

A => 11000010

11000010 is then converted to hexadecimal

11000010 = C2

Conclusively, the hexadecimal equivalent of the encrypted A is C2

8 0
2 years ago
Other questions:
  • Data Analysis The Iris Plants Database contains 3 classes of 50 instances each, where each class refers to a type of Iris plant.
    15·1 answer
  • ______ is a certification program that recognizes sustainable building practices and strategies. Question 1 options: A) Brundtla
    10·1 answer
  • Write a program that asks the user to input an integer that is a perfect square. A perfect square is an integer that is equal to
    14·1 answer
  • _____ computing refers to a computing environment that is always present, can feel our surroundings, and-based on who we are, wh
    8·1 answer
  • Axel is finally documenting his work. What could he be writing?
    12·1 answer
  • C++ :Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the outpu
    13·1 answer
  • ________ is a free online service that enables a user to contact a cell phone number to hear who answers the telephone without i
    5·1 answer
  • Write the state of the elements of each of the following arrays after each pass of the outermost loop of the selection sort algo
    11·1 answer
  • Write the notInVocab method. Assume that there are no duplicates in wordArray. You must call findWord and countNotInVocab approp
    10·1 answer
  • Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!