Skip to content

Commit 03df255

Browse files
Add files via upload
1 parent 472219d commit 03df255

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

forloop.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# program as for loop
2+
3+
a = [ ' rahul ' ,' is ', ' a ',' good ',' boy ']
4+
for x in a :
5+
print (x)
6+

pattern.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# program to print pattern
2+
# pattern 1
3+
''' n = int(input(" enter no of rows :"))
4+
while n >= 0:
5+
x = "*" * n
6+
print(x)
7+
n -= 1 '''
8+
9+
# pattern 2
10+
''' n = int ( input ( " enter rows :"))
11+
i = 1
12+
while i<=n:
13+
print("*" * i )
14+
i += 1 '''
15+
16+
# pattern 3
17+
rows = int ( input (" enter rows :"))
18+
n = rows
19+
while n >= 0 :
20+
x = "* " * n
21+
y = " " * ( rows - n)
22+
print( y + x )
23+
n -= 1
24+

powerseries.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# program to evaluate the power series
2+
# series looks like e**x =1+x+x**2/2! +x**3/3! +....+ x**n/n!
3+
# where 0 < x < 1
4+
5+
x = float(input("enter x :"))
6+
n = term = num = 1
7+
sum = 1.0
8+
while n<= 100:
9+
term *= x/n
10+
sum += term
11+
n += 1
12+
if term < 0.0001:
13+
break
14+
print(n,sum)

table.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# program to print multiplication table upto 10
2+
3+
i = 1
4+
while i < 11:
5+
n = 1
6+
while n <= 10:
7+
print((i*n) , end = ' ' )
8+
n += 1
9+
print()
10+
i += 1

0 commit comments

Comments
 (0)