Question: Practice Test: Python Programming Write a Python function to calculate the factorial of a given positive integer n. The factorial of n is the product

Practice Test: Python Programming

  1. Write a Python function to calculate the factorial of a given positive integer n. The factorial of n is the product of all positive integers less than or equal to n.

  2. Given a list of numbers, write a Python function to find and return the sum of all even numbers in the list.

  3. Create a Python class called Rectangle with attributes width and height. Add methods to calculate the area and perimeter of the rectangle.

  4. Write a Python function that takes a string as input and returns a new string with all vowels removed.

  5. Given a list of integers, write a Python function to find the largest and smallest numbers in the list.

  6. Create a Python function that takes two arguments, a and b, and returns their greatest common divisor (GCD). Use the Euclidean algorithm to find the GCD.

  7. Write a Python function that takes a list of words as input and returns a new list containing only the words with three or more vowels.

  8. Implement a Python function to check if a given number is a prime number. Return True if it's prime, otherwise False.

  9. Write a Python function that takes a list of numbers as input and returns a new list with the elements in reverse order.

  10. Create a Python class called Student with attributes name, age, and grades (a list of integers). Add methods to calculate the average grade and return a string representation of the student.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below Here are the answers to the practice test 1 Write a Python function to calculate the fact... View full answer

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 Programming Questions!