COP3502C Python Module 02 Lab solved

$30.00

Original Work ?
Category: Tags: , , , , You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Activity A

Calculate the equivalent resistance (R) of three resistors in parallel, given:
R =
1
1
R1
+
1
R2
+
1
R3
Program Inputs
• What is the value of R1?
• What is the value of R2?
• What is the value of R3?

– You can safely assume the user will always enter positive numbers for the resistors.
Program Outputs
• The equivalent resistance is XXX ohms
– Replace XXX with the equivalent resistance value

Sample Output
Test Case 1:
What is the value of R1? 10
What is the value of R2? 10
What is the value of R3? 20
The equivalent resistance is 4.0 ohms
Test Case 2:
What is the value of R1? 75
What is the value of R2? 10
What is the value of R3? 2200
The equivalent resistance is 8.79 ohms

Test Case 3:
What is the value of R1? 5000
What is the value of R2? 100
What is the value of R3? 22.5
The equivalent resistance is 18.3 ohms

Activity B

For a given length and width of a rectangle, write a program to calculate and display the perimeter,
area and the length of the diagonal of the rectangle.

Program Inputs
• Enter the length:
• Enter the width:
– You can safely assume the user will always enter real numbers for all questions.

Program Outputs
• Rectangle perimeter: XXX
– Replace XXX with the perimeter with at most 2 decimal places
• Rectangle area: YYY
– Replace YYY with the area with at most 2 decimal places
• Rectangle diagonal: ZZZ
– Replace ZZZ with the length of diagonal with at most 2 decimal places
Sample Output
Test Case 1:
Enter the length: 3
Enter the width: 8
Rectangle perimeter: 22.0
Rectangle area: 24.0
Rectangle diagonal: 8.54
Test Case 2:
Enter the length: 12.5
Enter the width: 35
Rectangle perimeter: 95.0
Rectangle area: 437.5
Rectangle diagonal: 37.17
Test Case 3:
Enter the length: 5.5
Enter the width: 6.3
Rectangle perimeter: 23.6
Rectangle area: 34.65
Rectangle diagonal: 8.36

Activity C

You are given two lines in slope-intercept form (y = mx + b) and must find their intersection
point. For example, if Line 1 is y = x and Line 2 is y = 3, then the intersect point is (3, 3).
Develop a program to find the intersection of any two lines (you can assume there will always be
an intersection!).

Program Inputs
• Enter m for Line 1:
• Enter b for Line 1:
• Enter m for Line 2:
• Enter b for Line 2:
– You can safely assume the user will always enter real numbers for all questions.
Program Outputs
• The intersection point is (XXX,YYY)
– Replace XXX with correct x coordinate and YYY with the y coordinate with at most 2
decimal places

Sample Output
Test Case 1:
Enter m for Line 1: 1
Enter b for Line 1: 0
Enter m for Line 2: 0
Enter b for Line 2: 3
The intersection point is (3.0,3.0)

Test Case 2:
Enter m for Line 1: 0.5
Enter b for Line 1: 1
Enter m for Line 2: -2
Enter b for Line 2: 20
The intersection point is (7.6,4.8)

Test Case 3:
Enter m for Line 1: 3
Enter b for Line 1: -5
Enter m for Line 2: 0.01
Enter b for Line 2: 2
The intersection point is (2.34,2.02)

Test Case 4:
Enter m for Line 1: 20
Enter b for Line 1: 0
Enter m for Line 2: -5.5
Enter b for Line 2: 50
The intersection point is (1.96,39.22)