Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
a = int(input())
b = int(input())

if 1<=a<=10**10 and 1<=b<=10**10:
print(a+b,a-b,a*b)


"""
OUTPUT:

input:
3

2

output:
5 1 6

"""
30 changes: 30 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

a =[]
n = int(input("Enter Range of Elements to be Sorted: "))
for i in range(0,n):
item=int(input())
a.append(item)
print('Unsorted List:',a)
a.sort()
print('Sorted List:',a)



"""
OUTPUT:

Enter Range of Elements to be Sorted: 5

4

2

6

8

3
Unsorted List: [4, 2, 6, 8, 3]
Sorted List: [2, 3, 4, 6, 8]

"""
16 changes: 16 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import datetime
s=input('Enter year, month, date: ')
year,month,day=map(int,s.split(','))
a_date = datetime.date(year,month,day)
week_number = a_date.isocalendar()[1]
print('Week Number =',week_number)



"""
OUTPUT:

Enter year, month, date: 2015,6,16
Week Number = 25

"""
34 changes: 34 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

from collections import Counter
classes={}
x=int(input("Enter Number of classes: "))
for i in range(x):
a=input("Enter Class: ")
b=input("Enter Number of students: ")
classes[a]=b

students = Counter(classes)
print(students)




"""
OUTPUT:

Enter Number of classes: 3

Enter Class: V

Enter Number of students: 6

Enter Class: VI

Enter Number of students: 4

Enter Class: VIII

Enter Number of students: 9
Counter({'VIII': '9', 'V': '6', 'VI': '4'})

"""
24 changes: 24 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def leap(y):
leap=False
if y % 400 == 0 or y % 4==0:
return True
elif y % 100 == 0:
return False
return leap

print(leap(int(input())))



"""
OUTPUT:

case 1:
1990
False

case 2:
2016
True

"""
31 changes: 31 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

from collections import OrderedDict
words=OrderedDict()
for i in range(int(input())):
eachword=input().strip()
words[eachword]=words.get(eachword,0)+1
print(len(words))
print(*words.values())




"""
OUTPUT:

input:
4

bcdef

abcdefg

bcde

bcdef

output:
3
2 1 1

"""
27 changes: 27 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
a=int(input())
b=int(input())
def gcd(a,b):
if (a==0):
return b
return gcd(b%a, a)
if (a>0 and a<=(10**12) and b>=1 and b<=(10**12)):
count=1
for i in range(2,gcd(a,b)+1):
if a%i==b%i==0:
count+=1
print(count)



"""
OUTPUT:

input:
10

15

output:
2

"""
17 changes: 17 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
string=str(input(''))
output="".join(dict.fromkeys(string))
print(output)



"""
OUTPUT:

input:
ababacd

output:
abcd


"""
81 changes: 81 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 6a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

def countSpecialElements(matrix):
nRows= len(matrix)
nCount=0

for row in matrix:
for indexCol, element in enumerate(row):

if element==min(row) or element==max(row):
if row.count(element)>1:
return -1
nCount=nCount+1

else:
listColumn=[]

for indexRow in range(0, nRows):
listColumn.append(matrix[indexRow][indexCol])

if element==min(listColumn) or element==max(listColumn):
if listColumn.count(element)>1:
return -1
nCount=nCount+1

return nCount


def slicing(a,step):
return [a[i::step] for i in range(step)]


matrixx = []
print("Enter the Elements Row Wise: ")

# For user input
a=[]
for i in range(3): # A for loop for row entries

for j in range(3): # A for loop for column entries
a.append(int(input()))
matrixx.append(a)
mat=slicing(a,3)
print(mat)


if __name__ == '__main__':
nCount = countSpecialElements(mat)
print(nCount)




"""
OUTPUT:

Enter the Elements Row Wise: #user input

1

5

8

3

2

7

4

9

6
[[1, 3, 4], [5, 2, 9], [8, 7, 6]] #output
7

"""



31 changes: 31 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 6b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
def not_poor(str1):
snot = str1.find('not')
spoor = str1.find('poor')


if spoor > snot and snot>0 and spoor>0:
str1 = str1.replace(str1[snot:(spoor+4)], 'good')
return str1
else:
return str1

i1=input()
i2=input()
print(not_poor(i1))
print(not_poor(i2))



"""
OUTPUT:

input:
​'The lyrics is not that poor!'

'The lyrics is poor!'

output:
​'The lyrics is good!'
'The lyrics is poor!'

"""
23 changes: 23 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
c=int(input("Enter Celcius: "))
f=int(((9*c)/5)+32)
f1=int(input("Enter Fahreheit: "))
c1=int(((f1-32)*5)/9)
print(c,"\N{DEGREE SIGN}C is",f,"in Fahreheit")
print(f1,"\N{DEGREE SIGN}F is",c1,"in Celsius")




"""
OUTPUT:

input:
Enter Celcius: 60

Enter Fahreheit: 45

output:
60 °C is 140 in Fahreheit
45 °F is 7 in Celsius

"""
23 changes: 23 additions & 0 deletions IP_LP3_Python_Rohan_Raval_2476/Question 8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def series(n):
if n < 1:
return 0
else:
return n + series(n - 2)

n=int(input('Enter Number: '))
print('Sum Series of',n,'=',series(n))



"""
OUTPUT:

case 1:
Enter Number: 6
Sum Series of 6 = 12

case 2:
Enter Number: 10
Sum Series of 10 = 30

"""
Loading