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
dybincka [34]
2 years ago
14

Create a Python program in a file named loops1.py that does the following: a. Use a while loop to keep asking the user for input

until the length of the input is at least 10. b. When the user finally enters an input that is 10 or more characters, proceed as follows: i. If the length of the input is even, print the input string back in all lowercase. ii. If the length of the input is odd, print the input string back in all uppercase.
Computers and Technology
2 answers:
Rashid [163]2 years ago
7 0

Answer:

mystr = input("Enter a string ")

length = len(mystr)

while length<10:

   mystr = input("Enter a string ")

   length = len(mystr)

   if(length>=10):

       break

if len(mystr)%2==0:

   print(mystr.lower())

else:

   print(mystr.upper())

Explanation:

The variable mystr is used to save user's input which is received with the input function

A second variable length is used to save the length of the input string Using a while statement the user is continually prompted to enter a string while length is less than 10.

If length is greater or equal to 10. We check for even or odd using the modulo (%) operator.

We use lower() and upper() to change the case of the string

Mandarinka [93]2 years ago
5 0

Answer:

myvalue = input("please input your value: ")

while len(myvalue) < 10 :

      myvalue = input("please input your value: ")

      if len(myvalue) >= 10:

               break

if len(myvalue)%2 == 0:

      print(myvalue.lower())

else:

       print(myvalue.upper())

Explanation:

Create a python program file and name the file as loops1.py in accordance to what the question stated. Note to run this file you must have installed python software on your system.

Interpreting the code,

myvalue = input("please input your value: ") simply prompt the user to input a value .

while len(myvalue) < 10 : and  myvalue = input("please input your value: ")  This is a while loop that prompts the user to input another values if the initial value length inputted is less than 10.

if len(myvalue) >= 10: If the length of the value is equal or greater than 10 then the break  statement terminates the while loop entirely.

if len(myvalue)%2 == 0:  If the length of the value inputted divided by 2 is equal to 0, the lower case version(print(myvalue.lower())) of the value is printed out.

else:  

The uppercase value is printed( print(myvalue.upper()))

NOTE python use indentation.

You might be interested in
Which two technologies support the building of single-page applications? and are two technologies helpful in building single pag
Sholpan [36]

Answer:

You can use JavaScript, HTML, PHP and so forth.

Explanation:

7 0
3 years ago
A hard drive that is running slowly may not have been
Anuta_ua [19.1K]
Plugged in i think is the answer
7 0
3 years ago
Read 2 more answers
A type of authentication that requires the user to provide something that they know, such
bagirrra123 [75]
The answer would be true
5 0
3 years ago
What's the main idea??
tatyana61 [14]
My computer wont let me download this pdf

7 0
2 years ago
Write c++ program to find maximum number for three variables using statement ?​
pantera1 [17]

Answer:

#include<iostream>

using namespace std;

int main(){

int n1, n2, n3;

cout<<"Enter any three numbers: ";

cin>>n1>>n2>>n3;

if(n1>=n2 && n1>=n3){

cout<<n1<<" is the maximum";}

else if(n2>=n1 && n2>=n3){

cout<<n2<<" is the maximum";}

else{

cout<<n3<<" is the maximum";}

return 0;

}

Explanation:

The program is written in C++ and to write this program, I assumed the three variables are integers. You can change from integer to double or float, if you wish.

This line declares n1, n2 and n3 as integers

int n1, n2, n3;

This line prompts user for three numbers

cout<<"Enter any three numbers: ";

This line gets user input for the three numbers

cin>>n1>>n2>>n3;

This if condition checks if n1 is the maximum and prints n1 as the maximum, if true

<em>if(n1>=n2 && n1>=n3){</em>

<em>cout<<n1<<" is the maximum";}</em>

This else if condition checks if n2 is the maximum and prints n2 as the maximum, if true

<em>else if(n2>=n1 && n2>=n3){</em>

<em>cout<<n2<<" is the maximum";}</em>

If the above conditions are false, then n3 is the maximum and this condition prints n3 as the maximum

<em>else{</em>

<em>cout<<n3<<" is the maximum";}</em>

return 0;

3 0
3 years ago
Other questions:
  • 7 features of QBASIC
    6·1 answer
  • Use the Internet and other sources to research the two disadvantages of standard biometrics: cost and error rates. Select one st
    10·1 answer
  • Alright, don't judge me, this is a question that involves my Childhood game PvZ GW 2. So I noticed mods and stuff that get uploa
    12·2 answers
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • What is the name given a technological program that typically copies itself and moves through a computer system in order to disr
    10·1 answer
  • What is computer sences​
    6·1 answer
  • Is this even possible
    9·2 answers
  • Write a SQL query to display films in inventory that have never been rented for all stores. Include inventory ID, film ID, film
    13·1 answer
  • Explain Http and Ftp​
    12·1 answer
  • Given a number n, for each integer i in the range from 1 to n inclusive, print one value per line as follows:
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!