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
brilliants [131]
4 years ago
12

Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent singl

e conditional.
Computers and Technology
1 answer:
victus00 [196]4 years ago
3 0

Answer:

following are the program to the given question:

Program:

x = 0#defining an integer variable that holds a value

if x < 0:#defining if that checks x less than 0

   print("This number ",  x, " is negative.")#print value with the message

else:#defining else block

   if x > 0:#defining if that checks x value greater than 0

       print(x, " is positive")#print value with message

   else:#defining else block

       print(x, " is 0")#print value with message

if x < 0:#defining another if that checks x less than 0

   print("This number ",  x, " is negative.")

elif (x > 0):#defining elif block that check x value greater than 0

   print(x, " is positive")#print value with message

else:#defining else block

   print(x, " is 0")#print value with message

Output:

Please find the attachment file.

Explanation:

In this code, an x variable is defined which holds a value that is "0", in the next step nested conditional statement has used that checks the x variable value and uses the print method that compares the value and prints its value with the message.

In another conditional statement, it uses if that checks x value less than 0 and print value with the negative message.

In the elif block, it checks x value that is greater than 0 and prints the value with the positive message, and in the else block it will print the message that is 0.

You might be interested in
The inflexible, circular platters on ____ disks use magnetic particles to store data, instructions, and information.
GREYUIT [131]
Hard disks use this method to store data. So your answer should be "hard".
3 0
4 years ago
2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte
Oduvanchick [21]

Answer:

Following are the code to this question:

def capital(val):#defining a method that takes string value as parameter

   x=True#defining boolean variable

   r=''#defining string variable  

   for i in val:#defining loop to convert the first character into upper case

       if i.isalpha() and x:#defining condition to check input value is string

           r=r+i.upper()#change value into uppercase and hold value in r variable

           x=False#assign value false in boolean variable

       elif i=='.' or i=='?' or i=='!':#check symbols

           r=r+i#add value in r variable

           x=True#assign value True in boolean variable

       else:

           r=r+i#add all value in r variable

   return r#return r variable value

val=input()#input value in val variable

print(capital(val))#called the function which print the return value

Output:

please find the attachment.

Explanation:

  • In the above python program, a method "capital" is declared, which accepts a "val" a string value in its parameter, and inside the method one boolean "x" and one string "r" variable is used, in which r stores return value.
  • In the next step, for loop is declared, inside the loop, the conditional statement is used, in if the block it checks string value and converts the first character into upper case and assigns value false in the boolean variable.  
  • In the next step, elif block is defined that adds value in r variable and at the last, it will return function value, at the last step "val" variable is declared that input value from the user and pass into the method and print its return value.

4 0
3 years ago
Cheng, a student, is researching a company's profile on a professional networking website. In what way will this kind of researc
vlada-n [284]

The way that this kind of research benefit her is by upgrading her knowledge.

<h3>What is research?</h3>

Research is known to  be a kind of making of new knowledge through the use of (or not) of previous knowledge in a novae and creative way.

Note that The way that this kind of research benefit her is by upgrading her knowledge as it will help her to have and get new concepts, methodologies and also have good understandings.

Learn more about research  from

om/question/968894

#SPJ1

5 0
2 years ago
The system tray contains _____.
MAXImum [283]
The operating system
8 0
4 years ago
Read 2 more answers
Marcus creates a HTML webpage on his favourite game, football. On clicking the word “football” another website containing the in
shtirl [24]
I can’t see the following tags that he could’ve possibly used
3 0
3 years ago
Other questions:
  • Hich of the following usually indicates that there is no moreinput to be read by a program?
    14·1 answer
  • how to create a program that prime number include arraylist , and if not print the prime factors of the number.
    13·1 answer
  • Signs that a listener is paying attention include:
    10·2 answers
  • Assessing opportunity cost involves...
    6·1 answer
  • Caitlyn's Crafty Creations computes a retail price for each product as the cost of materials plus $14 multiplied by the number o
    10·1 answer
  • When responding to an incident in which explosive materials are suspected, is it safe to use wireless communication devices?
    12·1 answer
  • Select the tips you should follow when writing a business report.
    12·1 answer
  • Describe PROM, EPROM and EEPROM memories​
    7·1 answer
  • What is the best memory to be used? Why?
    8·1 answer
  • You have studied graphic design, advanced math, and programming, and you
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!