Inventory application contd

• The work done so far
• What we want to acheive?
• We want a generic save method which will save the object to the csv file as a csv record
• We want to create a generic method to read the records from csv file as objects
• Refer Here for generic save implmentation
• Refer Here for the generic read implementation
• Changes summary
• We have used DictWriter from csv Refer Here and DictReader from csv Refer Here

Hacker Rank Problems

``````#!/bin/python3

import math
import os
import random
import re
import sys

if __name__ == '__main__':
n = int(input().strip())
if not 1 <= n<= 100:
exit(1)
if n%2 != 0:
print('Weird')
else:
if 2 <= n <= 5:
print('Not Weird')
elif 6 <= n <= 20:
print('Weird')
elif n>20:
print('Not Weird')

``````
``````if __name__ == '__main__':
a = int(input())
b = int(input())
if not 1 <= a <= 10**10:
# invalid value of a
exit(1)
if not 1 <= b <= 10**10:
# invalid value of b
exit(1)
print(a+b)
print(a-b)
print(a*b)

``````
``````if __name__ == '__main__':
a = int(input())
b = int(input())
if b == 0:
exit(1)
print(a//b)
print(a/b)
``````
``````if __name__ == '__main__':
n = int(input())
if not 1 <= n <= 20:
exit(1)
for index in range(n):
print(index**2)
``````
``````def is_leap(year):
leap = False

# Write your logic here
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
leap = True
else:
leap = False
else:
leap=True

return leap

year = int(input())
``````
``````if __name__ == '__main__':
n = int(input())
if not 1 <= n <= 150:
exit(1) # Return with error code
for index in range(n):
print(index+1,end='')
``````

This site uses Akismet to reduce spam. Learn how your comment data is processed.