WGU D335
WGU D335 Exam Introduction to
Programming in Python| Qs & As| Grade
A| 100% Correct -(NEW 2025/ 2026)
1. Create a solution that accepts an integer input. Import the built-in
module math and use its factorial() method to calculate the factorial of the
integer input. Output the value of the factorial, as well as a Boolean value
identifying whether the factorial output is greater than 100.: import math
fact = int(input()) x = math.factorial(fact)
print(
x) if x
>
100:
('Tru
e')
else:
print('False')
2. Create a solution that accepts any three integer inputs representing
the base (b1, b2) and height (h) measurements of a trapezoid in meters.
Output the exact area of the trapezoid in square meters as a float value.
The exact area of a trapezoid can be calculated by finding the average of
the two base measurements, then multiplying by the height measurement.
Trapezoid Area Formula:A = [(b1 + b2) / 2] * h: b1 = int(input()) b2 =
int(input()) h = int(input())
WGU D335
, 2
WGU D335
area_value = ((b1 + b2) /2) * h print('Trapezoid area:
{:.1f} square meters'.format(area_value))
3. Create a solution that accepts an integer input representing the age of
a pig. Import the existing module pigAge and use its pre-built
pigAge_converter() function to calculate the human equivalent age of a pig.
A year in a pig's life is equivalent to five years in a human's life. Output the
human-equivalent age of the pig.: import pigAge def
pigAge_converter(pig_age): return pig_age * 5 pig_age = int(input())
converted_pig_age = pigAge_converter(pig_age)
print(f'{pig_age} is {converted_pig_age} in human years')
4. Create a solution that accepts five integer inputs. Output the sum of
the five inputs three times, converting the inputs to the requested data
type prior to finding the sum.
First output: sum of five inputs maintained as integer values
Second output: sum of five inputs converted to float values
Third output: sum of five inputs converted to string values
(concatenate): num1 = int(input()) num2 = int(input()) num3 =
int(input()) num4 = int(input()) num5 = int(input())
first_output = num1 + num2 + num3 + num4 + num5
WGU D335