Skip to content

Commit ae99831

Browse files
committed
Updated
1 parent 6c38108 commit ae99831

File tree

10 files changed

+217
-0
lines changed

10 files changed

+217
-0
lines changed

Bisection Method/bisection.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
a = float(input("enter lower limit in which solution lies :"))
2+
b = float(input("enter upper limit in which solution lies :"))
3+
4+
x = a
5+
fa = x**2 + x - 6
6+
7+
x = b
8+
fb = x**2 + x - 6
9+
10+
f = fa * fb
11+
if (f > 0):
12+
print("given range does not exist solution")
13+
else:
14+
fc = 1
15+
k = 1
16+
while fc != 0:
17+
c = (a+b)/2
18+
x = c
19+
fc = x**2 + 3 * x - 10
20+
f = fa*fc
21+
print("k= a={} b= {} c={}".format(k, a, b, c))
22+
23+
if f < 0:
24+
b = c
25+
else:
26+
a = c
27+
k += 1
28+
29+
print("solution of given equation is {}".format(c))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def pwr(a, b):
2+
if b == 0:
3+
return (1)
4+
else:
5+
return (a*pwr(a, b-1))
6+
7+
8+
a = int(input("Enter Base Value :"))
9+
b = int(input("Enter Exponent Value :"))
10+
n = pwr(a, b)
11+
print(n)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
b = float(input("How many coulumns do you want?_"))
2+
a = float(input("How many rows do you want?_"))
3+
d = []
4+
l = 0
5+
while l < a:
6+
c = []
7+
k = 0
8+
while k < b:
9+
x = int(input("Enter the number_"))
10+
c.append(x)
11+
k += 1
12+
d.append(c)
13+
l += 1
14+
u = 0
15+
while u < len(d):
16+
v = 0
17+
while v < len(c):
18+
print(d[u][v], end=" ")
19+
v += 1
20+
u += 1
21+
print("\n")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
print("Marks sheet for class IX\n")
2+
3+
a = float(input("Enter Sindhi Obtained Marks : "))
4+
b = float(input("Enter English Obtained Marks : "))
5+
c = float(input("Enter PSt Obtained Marks : "))
6+
d = float(input("Enter Biology Obtained Marks : "))
7+
e = float(input("Enter Chemistry Obtained Marks : "))
8+
f = float(input("Enter Total Marks of All Subjects : "))
9+
10+
if f != 0:
11+
g = a+b+c+d+e
12+
13+
h = float(g/f)*100
14+
if f != 0 and f > g:
15+
print(h)
16+
if h >= 80:
17+
print("Grade: A+")
18+
if h >= 70 and h < 80:
19+
print("Grade: B")
20+
if h >= 60 and h < 70:
21+
print("Grade: C")
22+
if h >= 50 and h < 60:
23+
print("Grade: D")
24+
if h >= 40 and h < 50:
25+
print("Grade: E")
26+
if h >= 33.33 and h < 40:
27+
print("Grade: U")
28+
if h < 33.33:
29+
print("Grade: F")
30+
print("Mate you are failed!!!")

Patterns/patterns.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
print("R for \n*\n**\n***\n" + "S for \n***\n**\n*\n" + "T for Triangle of *\n")
2+
# print("S for \n***\n**\n*")
3+
# print("S for Triangle of *")
4+
5+
6+
inp = input("what kind of stars you want to print?_")
7+
8+
# Making right triangle of "*"
9+
if inp == "R":
10+
a = int(input("How many rows do you want?_"))
11+
b = "*"
12+
for k in range(a):
13+
print(b)
14+
b += "*"
15+
16+
# Making right triangle of "*" in inverse
17+
if inp == "S":
18+
a = int(input("How many rows do you want?_"))
19+
for i in range(a, 0, -1):
20+
for j in range(1, i+1):
21+
print("*", end=" ")
22+
print("\n")
23+
24+
# Making Triangle of *
25+
if inp == "T":
26+
a = int(input("How many rows do you want?_"))
27+
for i in range(a):
28+
for k in range(1, a-i):
29+
print(" ", end="")
30+
31+
for j in range(1, ((2*i)+2)):
32+
print("*", end=" ")
33+
print("\n")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
marks = [100, 99, 98, 97, 96, 44, 55, 66, 77, 88, ]
2+
3+
# sorting marks
4+
for i in range(len(marks)):
5+
min = i
6+
for j in range(i+1, len(marks)):
7+
if marks[j] < marks[min]:
8+
min = j
9+
t = marks[i]
10+
marks[i] = marks[min]
11+
marks[min] = t
12+
print(marks)
13+
14+
# printing top 5 marks
15+
a = 1
16+
for k in range(5):
17+
print(f" At Number {a} {marks[k]}")
18+
a += 1
19+
20+
# printing last 5 marks
21+
l = (len(marks)+1)-6
22+
i = 5
23+
for o in range(l, len(marks)):
24+
print(f" At {i} Last {l+1} {marks[l]}")
25+
l += 1
26+
i -= 1

README.md

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#funtion of matrix input from nested lists
2+
def inputmatrix (matrix):
3+
for i in range(len(matrix)):
4+
j=0
5+
for j in range(len((matrix)[j])):
6+
unsortedmatrix.append(matrix[i][j])
7+
return unsortedmatrix
8+
9+
#funtion of sorting
10+
def srt (unsortedmatrix):
11+
for k in range (len(unsortedmatrix)):
12+
for l in range (k+1, len(unsortedmatrix)):
13+
if unsortedmatrix[k] > unsortedmatrix[l]:
14+
pseudo = unsortedmatrix[l]
15+
unsortedmatrix[l] = unsortedmatrix[k]
16+
unsortedmatrix[k] = pseudo
17+
return unsortedmatrix
18+
19+
"_______________________________________MAIN PROGRAM_______________________________________"
20+
21+
#main program
22+
matrix=[[9,8,5],[7,1,2],[4,3,6]]
23+
Sortedmatrix=[]
24+
unsortedmatrix=[]
25+
inputmatrix(matrix)
26+
print(f"Unsortedmatrix: {unsortedmatrix}")
27+
srt(unsortedmatrix)
28+
print(f"Sortedmatrix: {unsortedmatrix}")
29+

Sum of Numbers/sumOfNumbers.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
a = []
2+
t = 0
3+
print('Write "c" to calculate the Total')
4+
x = float(input("numbers to be total_"))
5+
a.append(x)
6+
t = t+x
7+
while (x != "c"):
8+
x = (input("numbers to be total_"))
9+
if x != "c":
10+
x = float(x)
11+
a.append(x)
12+
t = t+x
13+
k = 0
14+
while k < len(a):
15+
if k != (len(a)-1):
16+
print(a[k], end=" + ")
17+
else:
18+
print(a[k])
19+
k += 1
20+
print(t)

Try Except/tryExcept.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# example 1
2+
a = float(input("Enter numerator :"))
3+
b = float(input("Enter denominator :"))
4+
if b != 0:
5+
c = (a/b)
6+
print(c)
7+
else:
8+
print("numerator can't be zero")
9+
10+
11+
# example 2
12+
a = float(input("Enter numerator :"))
13+
b = float(input("Enter denominator :"))
14+
try:
15+
c = (a/b)
16+
print(c)
17+
except:
18+
print("Error")

0 commit comments

Comments
 (0)