Skip to content

Commit 0cd53a5

Browse files
author
Sagar Paul
committed
DSA
1 parent 21d83e1 commit 0cd53a5

8 files changed

+87
-0
lines changed

DSA-problems/01.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
n = int(input("Wrrite a number here: \n"))
2+
3+
total_sum = 0
4+
for i in range(n+1):
5+
total_sum = total_sum + i
6+
7+
avg = total_sum/n
8+
print(f" Average of {n} numbers is {avg}")
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def fact(n):
2+
if n ==0:
3+
return 1
4+
else:
5+
return n*fact(n-1)
6+
7+
n = int(input("Write the number: \n"))
8+
print(f"Factorial of {n} is: {fact(n)}")
9+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
n = int(input("Enter the number: \n"))
2+
fact = 1
3+
for i in range(1,n+1):
4+
fact = fact*i
5+
print(f"factorial of {n} is: {fact}")
6+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'''
2+
*********
3+
* *
4+
* *
5+
* *
6+
* *
7+
* *
8+
* *
9+
**
10+
*
11+
12+
'''
13+
n = int(input("type the number: "))
14+
print("*"*n)
15+
for i in range(n,2,-1):
16+
print(" "*(n-i),"*"," "*(i-3),"*")
17+
print(" "*(n-1),"*"*2)
18+
print(" "*n,"*")
19+
20+
21+
22+
23+
24+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'''
2+
1
3+
2 3
4+
4 5 6
5+
7 8 9 10
6+
11 12 13 14 15
7+
8+
'''
9+
10+
n = int(input("type the number here: \n"))
11+
num = 1
12+
for row in range(1,n+1):
13+
for col in range(1,row+1):
14+
print(num, end=" ")
15+
num = num +1
16+
print()
17+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
word = "python"
2+
a = list(word)
3+
for row in range(len(a)+1):
4+
for col in range(row+1):
5+
print(a[col],end="")
6+
print()
7+
8+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Fibonacci Series 0,1,1,2,3,5,8,13,21,34
2+
3+
n = int(input("Type how many numbers your want : "))
4+
first = 0
5+
second = 1
6+
7+
for i in range(n):
8+
print(first)
9+
temp = first
10+
first = second
11+
second = temp+second
12+
13+
14+
File renamed without changes.

0 commit comments

Comments
 (0)