Skip to content

Commit 74b86f9

Browse files
Add files via upload
1 parent 03df255 commit 74b86f9

6 files changed

+73
-0
lines changed

continue.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# program for continue and break statement
2+
3+
while True:
4+
n = int (input("enter n :"))
5+
if n < 0 :
6+
continue #this will take the execution back to the starting of the loop
7+
elif n == 0 :
8+
break # this will get out of loop
9+
print(n**2) # if n>0 then square of no. print
10+
11+
print("thanks")

list.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
a = [' 1 ' , ' rahul ' , ' pi ' , ' 3.12 ' , ' linux ' ]
2+
print(a)
3+
print(a[0])
4+
print(a[1:4])
5+
print(a[0 : : 3])
6+
print(a[2: -2])

matrixmul.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
n = int(input("enter no. of rows and column :"))
2+
print("enter matrix a :")
3+
a = []
4+
for i in range (0,n) :
5+
a.append ([int (x) for x in input( " ") . split (" ")])
6+
print(" enter matrix b :")
7+
b = []
8+
for i in range(0,n):
9+
b.append([int(x) for x in input (" ").split(" ")])
10+
c = []
11+
for i in range (0,n):
12+
c.append([a [i] [j] * b [i] [j] for j in range (0, n )])
13+
print(" matrix c ")
14+
for x in c :
15+
for y in x :
16+
print(" %5d" %y , end=' ' )
17+
print( " " )
18+

palindrome.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# program to check a no. is palindrome or not .
2+
3+
s = input("enter the string :")
4+
z = s [ : : -1]
5+
if s == z :
6+
print("the string is palindrome ")
7+
else :
8+
print(" the string is not palindrome ")

sticksgame.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sticks = 21
2+
print(" there is total 21 sticks , we have to choose 1 - 4 sticks in a one chance ")
3+
print(" if any take last stick then loose the game ")
4+
while True :
5+
print("sticks left: " , sticks)
6+
sticks_taken = int (input(" take sticks :"))
7+
if sticks == 1:
8+
print("you took the last stick , game loose ")
9+
break
10+
if sticks_taken >= 5 or sticks_taken <= 0 :
11+
print("wrong choice")
12+
continue
13+
print("computer took :" , ( 5 - sticks_taken ) , "\n")
14+
sticks -= 5

student.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
n = int(input(" enter the no. of students : "))
2+
data = { }
3+
subject = ( ' Physics ' , ' Maths ' , ' history ' )
4+
for i in range (0 , n):
5+
name = input("enter the name of student %d : " % (i + 1))
6+
marks = []
7+
for x in subject :
8+
marks.append(int(input("enter marks of %s : " %x)))
9+
data[name] = marks
10+
for x, y in data.items():
11+
total = sum(y)
12+
print("%s ' s total marks %d " %(x,total))
13+
if total < 120:
14+
print("%s failed :" %x)
15+
else :
16+
print("%s passed :" %x)

0 commit comments

Comments
 (0)