Question: For Python 1. Convert the following code to an if-elif-else statement: if number == 1: print('One') else: if number == 2: print('Two') else: if number

For Python

1. Convert the following code to an if-elif-else statement:

if number == 1: print('One') else: if number == 2: print('Two') else: if number == 3: print('Three') else: print('Unknown')

2. Rewrite the following program by using nested if statement

age = int(input("Please enter your age:"))

if age < 13: print("You are a child.") elif age < 20: print("You are a teenager.") else: print("You are a adult.")

3. What does the following program do?

import random

secretNumber = random.randint(1, 100) print("I'm thinking of a secret number between 1 and 100...")

guess = int(input("What is your guess? "))

if (guess == secretNumber): print("you got it!") elif (guess > secretNumber): print("Sorry, your guess is too high.") else: print("Sorry, your guess is too low.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!