Commit 41a9825d authored by SAURAV YADAV's avatar SAURAV YADAV

Merge branch 'master' of https://git.cse.iitb.ac.in/yashap/inlab6

parents 873464dd a4dd1cf5
import pickle
from movies import Movie
name=input('Enter movie name: ')
rate=int(input('Enter rating of the movie: '))
with open('pickle.p','rb+') as f:
lst = pickle.load(f)
for i in lst:
if i.movieName == name:
i.rating = rate
break
else:
lst.append(Movie(name,rating))
for i in sorted(lst,key = lambda x : x.rating,reverse = True):
print(i.movieName, i.rating)
f.close()
f=open('pickle.p','wb')
pickle.dump(lst,f)
\ No newline at end of file
# Task1
# import random
# num=random.randint(1,9)
# while num==5:
# num=random.randint(1,9)
import time
num = str(time.time())[-2]
while num == '5':
num=str(time.time())[-2]
num=int(num)
guess=input('High or Low? :')
if guess.lower() == 'high' and num > 5:
print('Generated random number was {}. You guessed Correct.'.format(num))
elif guess.lower() == 'low' and num < 5:
print('Generated random number was {}. You guesses Correct.'.format(num))
else:
print('Generated random number was {}. You guessed Incorrect.'.format(num))
from movies import Movie
import pickle
with open('pickle.p','rb') as f:
l = pickle.load(f)
print('Movie, Rating')
for i in sorted(l,key = lambda x : x.rating,reverse = True):
print(i.movieName, i.rating)
class Movie(object):
def __init__(self, movieName='', rating = 0):
super(Movie, self).__init__()
self.movieName = movieName
self.rating = rating
\ No newline at end of file
from movies import Movie
import pickle
lstMovies = []
def addMovie(movie_name,rating):
lstMovies.append(Movie(movie_name,rating))
addMovie('some',4)
addMovie('strangerthings',7)
addMovie('f4',6)
addMovie('ted',5)
addMovie('je',4)
f=open('pickle.p','ab+')
pickle.dump(lstMovies,f)
f.close()
\ No newline at end of file
# TODO: take input from stdin and create student_db.csv
# USE ARGUMENT PARSER FOR THIS TASK
# IF file already exist append the new information.
# Display error if any argument is missing (i.e raise an error using try except)
import argparse
#overwrite parse.error
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment