https://github.com/imdarshangk/functions
This repository contains various Python programs that demonstrate the use of functions with and without return values and arguments. The programs cover different mathematical operations and concepts.
https://github.com/imdarshangk/functions
factorial function-with-return-with-arguments function-with-return-without-arguments function-without-return-with-arguments function-without-return-without-arguments functional-programming functions python
Last synced: 8 months ago
JSON representation
This repository contains various Python programs that demonstrate the use of functions with and without return values and arguments. The programs cover different mathematical operations and concepts.
- Host: GitHub
- URL: https://github.com/imdarshangk/functions
- Owner: imDarshanGK
- Created: 2023-03-04T16:57:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T17:34:35.000Z (11 months ago)
- Last Synced: 2024-12-13T18:32:28.910Z (11 months ago)
- Topics: factorial, function-with-return-with-arguments, function-with-return-without-arguments, function-without-return-with-arguments, function-without-return-without-arguments, functional-programming, functions, python
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Functions 🧮
## Overview 🔍
This repository contains Python programs demonstrating various types of functions. The projects showcase how functions can be utilized to perform tasks like calculations, data manipulation, and more. It serves as an educational resource to understand how functions work in Python.
## Features 💡
- Examples of different function types: simple, recursive, lambda functions, and more.
- Clear, commented code for easy understanding.
- Ideal for beginners learning Python functions.
## Function with return with arguments
Function with return with arguments
```
program 1: squaare and cube
64
36
49
125
program 2: sum and mul and average
x= 12 y= 48 z= 4.0
program 3: square root and cube root and power
p= 6.0 q= 3.0 r= 16
program 4:sum and factorial
p= 1035 q= 230843697339241380472092742683027581083278564571807941132288000000000000
```
## Function with return without arguments
solution
```
Program 1: Square and Cube
Enter a number to find cube:2
8
Enter a number to find square:3
9
Enter a number to find square:5
25
Enter a number to find cube:6
216
Program 2: Square root and Cube root power
Enter a number:12
Enter a number:24
Enter base:3
Enter exponential:5
p= 3.4641016151377544 q= 2.8844991406148166 r= 243
Program 3: Sum and factorial
Enter a number to find sum:5
Enter a number to find factorial:6
p= 15 q= 720
Program 4: Sum and mul and average
Enter a:12
Enter b:6
Enter c:8
Enter a:9
Enter b:7
Enter c:5
Enter a:4
Enter b:3
Enter c:1
x= 26 y= 315 z= 2.6666666666666665
```
## Function without return with arguments
Function without return with arguments.
```
Program :1}cube and square
Cube= 8
Square= 9
Square= 16
Cube= 27
Program :2}sum and mul and average
sum= 14
sum= 14
product= 48
product= 96
average= 4.0
average= 5.666666666666667
Program :3}square root and cube root and power
square root= 6.0
square root= 9.0
cube root= 3.0
cube root= 3.9999999999999996
power= 16
power= 9
Program :4}sum and factorial and info
sum= 15
sum= 10
factorial= 120
factorial= 24
Name= Rakesh Age= 24 percentage= 80.33
Name= Ram Age= 35 percentage= 77.33
Program :5}simple interest and rectangle and circle
simple interest= 9000.0
simple interest= 32000.0
Area of rectangle= 72 perimeter= 36
Area of rectangle= 112 perimeter= 44
Area= 72.39168 circumfarence= 30.163199999999996
Area= 120.77848 circumfarence= 38.9608
Program :6}sum and factorial
Enter a:2
Enter b:3
sum= 3
sum= 6
Enter c:2
Enter d:6
factorial= 2
factorial= 720
```
## Function without return without arguments
Function without return without arguments.
Funtions defination:
```
It is the group statement this excuited when function calls.
```
```
Program 1)Good Morning
Good Morning
Good Afternoon
Good Morning
Good Afternoon
Program 2:Square and cube
Enter a number to find cube:12
Cube= 1728
Enter a number to find square:10
Square= 100
Enter a number to find square:6
Square= 36
Enter a number to find cube:5
Cube= 125
Program 3:Sum and product and average
Enter a:2
Enter b:6
Enter c:83
sum= 91
Enter a:9
Enter b:84
Enter c:5
sum= 98
Enter a:9
Enter b:78
Enter c:2
product= 1404
Enter a:1
Enter b:5
Enter c:6
product= 30
Enter a:9
Enter b:8
Enter c:4
average= 7.0
Enter a:9
Enter b:7
Enter c:5
average= 7.0
Program 4:Square root and Cube root and Power
Enter a number:8
square root= 2.8284271247461903
Enter a number:6
square root= 2.449489742783178
Enter a number:9
cube root= 2.080083823051904
Enter a number:7
cube root= 1.912931182772389
Enter base:5
Enter exponential:4
power= 625
Enter base:3
Enter exponential:2
power= 9
Program 5:Sum and Factorial and Info
Enter a number to find sum:3
sum= 6
Enter a number to find sum:8
sum= 36
Enter a number to find factorial:7
factorial= 5040
Enter a number to find factorial:4
factorial= 24
Enter name:9
Enter age:5
Enter percentge:1.0
Name= 9 Age= 5 percentage= 1.0
Enter name:6
Enter age:54
Enter percentge:9
Name= 6 Age= 54 percentage= 9.0
Program 6: Simple interest and Rectangle and Circle
Enter principle:5
Enter time:6
Enter rate:9
simple interest= 2.7
Enter principle:7
Enter time:2
Enter rate:4
simple interest= 0.56
Enter length:5
Enter breadth:6
Area of rectangle= 30 perimeter= 22
Enter length:9
Enter breadth:4
Area of rectangle= 36 perimeter= 26
Enter radius:5
Area= 78.55 circumfarence= 31.419999999999998
Enter radius:2
Area= 12.568 circumfarence= 12.568
```
## def Factorial
def Factorial
```
Example 1:
Enter a number to find factorial: 25
factorial= 1
factorial= 2
factorial= 6
factorial= 24
factorial= 120
factorial= 720
factorial= 5040
factorial= 40320
factorial= 362880
factorial= 3628800
factorial= 39916800
factorial= 479001600
factorial= 6227020800
factorial= 87178291200
factorial= 1307674368000
factorial= 20922789888000
factorial= 355687428096000
factorial= 6402373705728000
factorial= 121645100408832000
factorial= 2432902008176640000
factorial= 51090942171709440000
factorial= 1124000727777607680000
factorial= 25852016738884976640000
factorial= 620448401733239439360000
factorial= 15511210043330985984000000
Enter a number to find factorial: 10
factorial= 1
factorial= 2
factorial= 6
factorial= 24
factorial= 120
factorial= 720
factorial= 5040
factorial= 40320
factorial= 362880
factorial= 3628800
Enter a number to find factorial: 5
factorial= 1
factorial= 2
factorial= 6
factorial= 24
factorial= 120
Example 2:
Enter a number to find factorial: 5
factorial= 1
factorial= 2
factorial= 6
factorial= 24
factorial= 120
Enter a number to find factorial: 4
factorial= 1
factorial= 2
factorial= 6
factorial= 24
Enter a number to find factorial: 3
factorial= 1
factorial= 2
factorial= 6
```
## Factorial of n using recursive function
Factorial of n using recursive function
```
Explanation :
factorial(7)
7*factorial(6)=5040
720*7
6*factorial(5)=720
120*6
5*factorial(4)=120
24*5
4*factorial(3)=24
6*4
3*factorial(2)=6
2*1
2*factorial(1)=2
output:
Result= 5040
```
## Finding power using recursive function
Finding power using recursive function
```
output:
result= 1024
Explanation:
power(4,5)=1024
256*4
4*power(4,4)=256
64*4
4*power(4,3)=64
16*4
4*power(4,2)=16
4*4
4*power(4,1)=4
4*1
```
## Recursive Function sum of n integers using recursive function
```
sum of n integers using recursive function
def Function which calls itself repetedly till stopping condition occurs.
sum of n integers using recursive function.
```
## Recursive Function:
```
Function which calls itself repetedly till stopping condition occurs.
```
```
output:
result= 21
```
## square and cube
square and cube
```
output:
27
4
9
64
```