Question

In: Computer Science

python Show an example of three sequential and independent if blocks (make up your own) and...

python

Show an example of three sequential and independent if blocks (make up your own) and Show an example of a nested if block (make up one of your own).

Solutions

Expert Solution

An example of three sequential and independent if blocks is given below:

#get user input
x = int(input("Enter a number \nx = "))

#check if the value of x is greater than 10
if x > 10:
print("x is greater than 10")
  
#check if the value of x is greater than 100
if x > 100:
print("x is greater than 100")

#check if the value of x is less than 100
if x < 100:
print("x is less than 100")

The screenshot of the above source code is given below:

OUTPUT:

Enter a number
x = 50
x is greater than 10
x is less than 100

An example of a nested if block is given below:

#get user input
x = int(input("Enter a number \nx = "))

#check if the value of x is greater than 10
if x > 10:
#check if the value of x is greater than 100
if x > 100:
print("x is greater than 100")

  

The screenshot of the above source code is given below:

OUTPUT:

Enter a number
x = 150
x is greater than 100




Related Solutions

Make up your own example to show that teh Poisson distribution is not memoryless.
Make up your own example to show that teh Poisson distribution is not memoryless.
Create an example (make up your own numbers) for a virtual open economy with import as...
Create an example (make up your own numbers) for a virtual open economy with import as a function of total income. Find the equilibrium output level and the open economy multiplier.
Create an example (make up your own numbers) for a virtual open economy with import as...
Create an example (make up your own numbers) for a virtual open economy with import as a function of total income. Find the equilibrium output level and the open economy multiplier. ı sent this question before but I couldn't read most of the answer.
Make up a two-way ANOVA example. (Create your own example.) First write the question. Then analyze...
Make up a two-way ANOVA example. (Create your own example.) First write the question. Then analyze your question. Identify the research question, variable of interest, and factors. Then explain how data should be collected for this question (you may suggest some intuitive numbers for data collection). Finally what will be your hypotheses (3 of them) to test your research question?
Make up a Bayes example from DAILY life(Create your own exaample) First write question and analyze...
Make up a Bayes example from DAILY life(Create your own exaample) First write question and analyze your question. Explain the differences between conditional probabilities;explain the meaning of those conditional probabilities. You may assign probabilities to events in the question or may use historical observations for empirical probabilities.
1. Describe three of the biases or types of framing and make up an example of...
1. Describe three of the biases or types of framing and make up an example of how each might impact an investment decision. 2. If markets are efficient, how is it possible that market bubbles and crashes occur?
1. Describe three of the biases or types of framing and make up an example of...
1. Describe three of the biases or types of framing and make up an example of how each might impact an investment decision. 2. If markets are efficient, how is it possible that market bubbles and crashes occur?
1. Describe three of the biases or types of framing and make up an example of...
1. Describe three of the biases or types of framing and make up an example of how each might impact an investment decision. 2. If markets are efficient, how is it possible that market bubbles and crashes occur?
Make up an example to show that Dijkstra’s algorithm fails if negative edge lengths are allowed.
Make up an example to show that Dijkstra’s algorithm fails if negative edge lengths are allowed.
Provide example of your own research question. Formulate hypothesis for your research question and independent and...
Provide example of your own research question. Formulate hypothesis for your research question and independent and dependent variables for this question.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT