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
amid [387]
3 years ago
15

Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in

one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String to display, and then output the correct list. For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings, output The list is empty. Prompt the user continuously until a sentinel value, ZZZ, is entered.
Computers and Technology
1 answer:
notsponge [240]3 years ago
3 0

Answer:

count = 20

i = 0

short_strings = []

long_strings = []

while(i<count):

   s = input("Enter a string: ")

   

   if s == "ZZZ":

       break

   

   if len(s) <= 10:

       short_strings.append(s)

   elif len(s) >= 11:

       long_strings.append(s)

   

   i += 1

choice = input("Enter the type of list to display [short/long] ")

if choice == "short":

   if len(short_strings) == 0:

       print("The list is empty.")

   else:

       print(short_strings)

else:

   if len(long_strings) == 0:

       print("The list is empty.")

   else:

       print(long_strings)

Explanation:

*The code is in Python.

Initialize the count, i, short_strings, and long_strings

Create a while loop that iterates 20 times.

Inside the loop:

Ask the user to enter a string. If the string is "ZZZ", stop the loop. If the length of the string is smaller than or equal to 10, add it to the short_strings. If the length of the string is greater than or equal to 11, add it to the long_strings. Increment the value of i by 1.

When the loop is done:

Ask the user to enter the list type to display.

If the user enters "short", print the short list. Otherwise, print the long_strings. Also, if the length of the  chosen string is equal to 0, print that the list is empty.

You might be interested in
Consider the following statements. An abstract class is better than an interface when the variables in the abstract class or int
Ksivusya [100]
Well the nonchalant question given for 4th grade red named babyface Justin and Jerome
4 0
2 years ago
24
gogolik [260]

Answer:

OC

Explanation:

I am not so sure about this though as I am not familiar with a webmail service. I hope this helped. Sorry, if it wasn't much of an help though

7 0
2 years ago
Read 2 more answers
What is the index of 7 in this list?<br> [5, 6, 10, 7, 3, 2.51]
kotykmax [81]
5 or 7 I believe Good luck!
6 0
2 years ago
Read 2 more answers
Write a program that accepts a time as an hour and minute. Add 15 minutes to the time, and output the result. Example 1: Enter t
Liula [17]

Answer:

Explanation:

C++ Code

#include <iostream>

#include <cstdlib>

using namespace std;

int main(){

double hour,minute;

cout<<"Enter Hours :";

cin>>hour;

cout<<"Enter Minutes :";

cin>>minute;

minute = minute+15;

if(minute >=60){

 hour++;  

 minute = minute-60;

}

if(hour>23){

 hour = 0;

}

cout<<"Hour: "<< hour<< " Minutes: "<<minute;

return 0;  

}

Code Explanation

First take hours and minutes as input. Then add 15 into minutes.

If minutes exceeds from 60 then increment into hours and also remove 60 from minutes as hours already incremented.

Then check if hours are greater then 23 then it means new day is start and it should be 0.

Output

Enter Hours :9

Enter Minutes :46

Hour: 10 Minutes: 1

5 0
2 years ago
D. The 7-bit ASCII code for the character '&amp;' is:
insens350 [35]

Answer:

00100110

a and d are invalid sequences because they contain an even number of 1's.

Explanation:

Odd parity means that you want an odd number of 1's in the resulting set of bits. Since there are 3 (=odd) bits in the set, a zero must be added to keep the total odd.

6 0
3 years ago
Other questions:
  • Jameis is researching at his local library when he finds a perfect source to use in his paper. When he goes to check the book ou
    12·2 answers
  • The general syntax for the function prototype to overload the assignment operator = for a class is ____.a. friend className&amp;
    8·1 answer
  • Match the steps with the actions that are involved when an internal host with IP address 192.168.10.10 attempts to send a packet
    11·1 answer
  • Okay so remember that page I was advertising? At: fol ? Now it's deleted. And idk why because I was doing everything the right w
    7·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • List the step in turning on a computer
    6·1 answer
  • Secondary hard drive whats its purpose
    5·1 answer
  • can someone tell me what to do i’m kinda stuck and don’t know what he’s telling me to do pls ill give brainlist and points
    13·1 answer
  • PLS HELP IM SO DESPERATE!! 40 points
    7·1 answer
  • Complete the following sentences using each of the words provided ONCE only. KEYBOARD DESKTOP STORE PRINTER COMPUTER MOUSE MONIT
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!