title | type | duration | creator | ||||
---|---|---|---|---|---|---|---|
Python Function Practice |
Lab |
1:5 |
|
In this lab, we're going to practice writing simple functions.
- Write a function with one argument. Find the area of a square.
- Write a function with two arguments. Find the area of a rectangle.
- Write a function with three arguments. Find the surface area of cuboid.
Bonus:
-
Write a function to find the Max of three numbers.
-
Write a function to sum all the numbers in a list. Sample List : (8, 2, 3, 0, 7) Expected Output : 20
-
Write a function to multiply all the numbers in a list. Sample List : (8, 2, 3, -1, 7) Expected Output : -336
-
Write a function to reverse a string. Sample String : "1234abcd" Expected Output : "dcba4321"
-
Write a function to calculate the factorial of a number (non-negative integer). The function accept the number as a argument.
-
Write a function to check whether a number is in a given range.
-
Write an function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 12
-
Write an function that takes a list and returns a new list with unique elements of the first list. Sample List : [1,2,3,3,3,3,4,5] Unique List : [1, 2, 3, 4, 5]
-
Write a function that takes a number as a parameter and check the number is prime or not. Note : A prime number (or a prime) is a natural number greater than 1 and that has no positive divisors other than 1 and itself.
-
Write a function to print the even numbers from a given list. Sample List : [1, 2, 3, 4, 5, 6, 7, 8, 9] Expected Result : [2, 4, 6, 8]
Here is a link to the starter code