Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Lab 1 Python

Uploaded by

naveendeswal180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab 1 Python

Uploaded by

naveendeswal180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 1 Python.

For each problem copy your code/ input and output data (your answers).

Problem 1 (Demo)
Write a script that will check if the integer number entered by user is even, odd, or zero.

Problem 2
Experiment, in the Console Window, with using the print function for real numbers. Make
a note of what happens for each. Use print to print the real number 12345.6789.

• without specifying any field width


• in a field width of 10 with 4 decimal places
• in a field width of 2 with 2 decimal places

Problem 3
Write a script that will calculate value of the function z. It prompts the user for two
integers x and t, calculates z and prints it with 2 decimal places.

9𝜋𝑡 + 10cos (𝑥) !


𝑧= ∗𝑒
√𝑡 − |sin (𝑡)|
Test you script with:
x=10, t=1.
Problem 4
Write a script that prompts the user for an integer number n and calculates and prints
n+nn+nnn .
Here is an example of running it:

Enter an integer number n: 2


The n + nn + nnn = 246

Problem 5
Write a script areaMenu that will print a list consisting of “cylinder”, “circle”, and
“rectangle”. It prompts the user to choose one, and then prompts the user for the
appropriate quantities (e.g., the radius of the circle) and then prints its area. If the user
enters an invalid choice, the script simply prints an error message. The script should use a
if-elif-else statement to accomplish this.
Here are two examples of running it (units are assumed to be inches).

See next page


>> areaMenu
Menu
1. Cylinder
2.Circle
3.Rectangle
Please choose one:2

Enter the radius of the circle in in.: 4.1


The area is 52.81 in^2

>> areaMenu
Menu
1. Cylinder
2.Circle
3.Rectangle

Please choose one:3

Enter the length in in: 4


Enter the width in in: 6
The area is 24.00 in^2

You might also like