Question
1- Make a program that uses selections and sqrt Using the IDLE write an improved version of the program that uses sqrt allowing only positive
1- Make a program that uses selections and sqrt
Using the IDLE write an improved version of the program that uses sqrt allowing only positive numbers using an if-else statement.
Add the program below: |
|
Provide the screenshot of the run-output.
2- Writing a program that uses selections and random
Using the IDLE, write a program that generates a random number from -10 to 10 and says if it is positive, negative or zero, and if it is even or odd (3 is odd, 2 is even, 1 is odd, 0 is considered even).
Add the program below: |
|
Provide the screenshot of the run-output.
3- Writing a program with if-else-elif statements
Using the IDLE write a program that asks for a name, and if the name starts with Dr, it replies Hello Dr!, if it begins with Eng, it replies Hello Eng! and if none of the previous is met, it replies Hello Mr!.
Use the slice operator ([a:b]) to get a sub-string from the name and the method .lower() to make a lower case of it to compare for all cases at once. For example, it must say Hello Dr! for names that begin with:
DR, dr, Dr.
Add the program below: |
|
Provide the screenshoot of the run-output.
4- Writing a program that makes a conditioned swap
Using the IDLE, write a program that asks 2 numbers and provide them sorted from the bigger to the smaller.
Add the program below: |
|
Provide the screenshot of the run-output.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started