UCEST 105 Lab Cycle - 4

Learning Objective:
  • Learn to write functions and recursive functions
Functions and Recursive Functions
1.Write a function to check whether the given number is even or odd. ( return True or False)
2.Write a function to find the sum of numbers between a lower bound and an upper bound
3.A program that accepts the lengths of three sides of a triangle as inputs. The program should output whether or not the triangle is a right triangle (Recall from the Pythagorean Theorem that in a right triangle, the square of one side equals the sum of the squares of the other two sides). Implement using functions.
4.Write a function that returns True if a given number is prime and False otherwise.Use this function to print all prime numbers less than N. Read N. Use the same function to print n'th prime number.
5.Write a Python program to calculate the area of a circle, given the center and a point on the perimeter. Use a function to find the radius as the distance between two points.
6.Compute nCr and nPr. Read 'n' and 'r'. Use your own factorial function ( recursive) and function to compute nCr and nPr.
7. Recursive function to add two positive numbers.
8. Recursive function to multiply two positive numbers.
9. Recursive function to find the greatest common divisor of two positive numbers.
10. Write a recursive function to generate n'th Fibonacci number.Use this function to generate Fibonacci series.
11. Program to check whether the given number is a valid mobile number or not using functions.
Rules:
1. Every number should contain exactly 10 digits.
2. The first digit should be 7 or 8 or 9
12.To print n lines of the following pattern. using a function
2
2 4
2 4 6
2 4 6 8
13.Print prime factors of a number. Use the function isPrime(n) for checking primality.
14.Write a recursive function to reverse a string.
15.Write a recursive function to calculate the power of a number ( x^n)
16.Write lambda functions for the following functions f(x)=x^2+3x+2 and g(x,y)=2x^3+3y^2+4xy+2




Comments

Popular posts from this blog

Algorithmic Thinking with Python UCEST 105- KTU First Semester BTech Course 2024 scheme notes pdf - Dr Binu V P 9847390760

Lab Experiments and Solutions - Algorithmic thinking with Python KTU S1 2024 scheme

UCEST 105 Lab Cycle - 1