diff --git a/Challenge questions/manojathreya/1.py b/Challenge questions/manojathreya/1.py new file mode 100644 index 0000000..0d2ea3d --- /dev/null +++ b/Challenge questions/manojathreya/1.py @@ -0,0 +1,16 @@ +#@author:Manoj Athreya A + +#write a program to print occurance count of all the characters of a string. + +str="Good Morning" +d=dict() +count=0 +for char in str: + if char in d: + d[char]=d[char]+1 + else: + d[char]=1 +print(d) + +#OUTPUT: {'G': 1, 'o': 3, 'd': 1, ' ': 1, 'M': 1, 'r': 1, 'n': 2, 'i': 1, 'g': 1} + diff --git a/Challenge questions/manojathreya/2.py b/Challenge questions/manojathreya/2.py new file mode 100644 index 0000000..3a031e0 --- /dev/null +++ b/Challenge questions/manojathreya/2.py @@ -0,0 +1,29 @@ +#@author:Manoj Athreya A + +#Vacation Caluclator +def hotel_cost(days): + return 140 * days + +def plane_ride_cost(city): + if city == "Charlotte": + return 183 + elif city == "Tampa": + return 220 + elif city == "Pittsburgh": + return 222 + elif city == "Los Angeles": + return 475 + +def rental_car_cost(days): + cost = days * 40 + if days >= 7: + cost -= 50 + elif days >= 3: + cost -= 20 + return cost + +def trip_cost(city, days, spending_money): + return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money + +print (trip_cost("Los Angeles", 5, 600)) +#1955 \ No newline at end of file diff --git a/Challenge questions/manojathreya/3.py b/Challenge questions/manojathreya/3.py new file mode 100644 index 0000000..87885a2 --- /dev/null +++ b/Challenge questions/manojathreya/3.py @@ -0,0 +1,27 @@ +#@author:Manoj Athreya A + +#Class Program +class A: + def __init__(self,val1,val2): + self.__a=val1 + self.b=val2 + def display(self): + print(self.__a,self.b) + +class B(A): + def __init__(self,v1,v2,v3): + super().__init__(v1,v2) + self.__c=v3 + def display(self): + super().display() + print(self.__c) + print(self.b) + +obj=B(10,20,30) +obj.display() +# ============================================================================= +# #output: +# 10 20 +# 30 +# 30 +# ============================================================================= \ No newline at end of file diff --git a/Challenge questions/manojathreya/4.py b/Challenge questions/manojathreya/4.py new file mode 100644 index 0000000..dcba4d0 --- /dev/null +++ b/Challenge questions/manojathreya/4.py @@ -0,0 +1,55 @@ +#@author:Manoj Athreya A + +#DATABASE CREATION + +import sqlite3 + +conn=sqlite3.connect('movie.sqlite') +cur=conn.cursor() + +cur.execute('DROP TABLE IF EXISTS Movies') + +cur.execute('CREATE TABLE Movies(title TEXT,ratings INTEGER)') +cur.execute('INSERT INTO Movies(title,ratings) VALUES (?,?)',('KGF',5)) +cur.execute('INSERT INTO Movies(title,ratings) VALUES (?,?)',('Natasarvabhouma',3)) +cur.execute('''INSERT INTO MOVIES VALUES('Yajamana','4')''') +cur.execute('''INSERT INTO MOVIES VALUES('99','3.5')''') +cur.execute('SELECT * FROM Movies') + +for row in cur: + print(row) + +cur.execute('SELECT title,ratings FROM Movies') +for row in cur: + print(row) + +# ============================================================================= +# OUTPUT: +# ('KGF', 5) +# ('Natasarvabhouma', 3) +# ('Yajamana', 4) +# ('99', 3.5) +# ============================================================================= + +cur.execute('SELECT title FROM Movies') +for row in cur: + print(row) +# ============================================================================= +# OUTPUT: +# ('KGF',) +# ('Natasarvabhouma',) +# ('Yajamana',) +# ('99',) +# ============================================================================= +cur.execute('SELECT ratings FROM Movies') +for row in cur: + print(row) +# ============================================================================= +# OUTPUT: +# (5,) +# (3,) +# (4,) +# (3.5,) +# ============================================================================= +cur.close() +conn.close()