From 596ee0ce6b658b68055f161fd9d28f8afdd7e04d Mon Sep 17 00:00:00 2001 From: "Ingle, Karan (US - Mumbai)" Date: Wed, 2 Aug 2017 20:00:49 +0530 Subject: [PATCH 1/2] Written an awesome API call --- api-repo.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 api-repo.py diff --git a/api-repo.py b/api-repo.py new file mode 100644 index 0000000..6bdbbb2 --- /dev/null +++ b/api-repo.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +import requests +import json + +# main api url +url = 'https://api.github.com/users/' + + +# put your username/password here +#auth = ('myUsername', 'myPassword') + +# request an authorization token from the server +#response = requests.get(url + '/user/authentication', +# auth=auth, verify=False).json() + +# get the token from the response +#token = response['authToken']['token'] + +# to make an api call using this token, +# add a token parameter to the request +#params = { +# 'token': token, +# 'start': '2014-01-15', +# 'end': '2014-02-01', +# 'geoJSON': 1, +# 'limit': 10 +#} +name = raw_input("What is your name? ") + +if name != "": + response = requests.get(url + name).json() +else: + print "Please enter a GITHub username." +# response contains the geoJSON object, +# pretty print it to the console +#print json.dumps(response, indent=4) +if response['login'] != None: + print "+++++++++++++++++++++++++++++++++++++++++" + print "My master's name is "+response['login'] + if response['bio'] != None: + print "++++++++++++" + print "And his identity is: "+response['bio'] + print "+++++++++++++++++++++++++++++++++++++++++" + else: + print "He is too lazy to write a bio" +else: + print "This is not my master!!!!" \ No newline at end of file From 3e993e95409d0ad32ba10fc7b7693cf500fa4efe Mon Sep 17 00:00:00 2001 From: "Ingle, Karan (US - Mumbai)" Date: Sun, 6 Aug 2017 15:34:00 +0530 Subject: [PATCH 2/2] backing up projects from week 2 --- .vscode/settings.json | 3 +++ api-repo.py | 6 ++++++ books/author.py | 11 +++++++++++ books/author.pyc | Bin 0 -> 926 bytes books/book.py | 23 +++++++++++++++++++++++ books/book.pyc | Bin 0 -> 1237 bytes books/run_library.py | 16 ++++++++++++++++ fibo.py | 20 ++++++++++++++++---- hello.py | 20 ++++++++++---------- hello.pyc | Bin 0 -> 255 bytes marks.py | 9 +++++++++ student.py | 2 -- student/student.py | 17 +++++++++++++++++ student/student.pyc | Bin 0 -> 370 bytes student/studentlib.py | 24 ++++++++++++++++++++++++ student_class.py | 24 ++++++++++++++++++++++++ student_class.pyc | Bin 0 -> 1402 bytes student_input.py | 28 ++++++++++++++++++++++++++++ student_ops.py | 14 ++++++++++++++ student_ops.pyc | Bin 0 -> 706 bytes testing/__init__.py | 0 testing/__init__.pyc | Bin 0 -> 157 bytes testing/matlib/__init__.py | 0 testing/matlib/__init__.pyc | Bin 0 -> 164 bytes testing/matlib/math_ops.py | 5 +++++ testing/matlib/math_ops.pyc | Bin 0 -> 398 bytes testing/matlib/series.py | 16 ++++++++++++++++ testing/matlib/series.pyc | Bin 0 -> 847 bytes while.py | 34 ++++++++++++++++++++++++++++++++++ 29 files changed, 256 insertions(+), 16 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 books/author.py create mode 100644 books/author.pyc create mode 100644 books/book.py create mode 100644 books/book.pyc create mode 100644 books/run_library.py create mode 100644 hello.pyc create mode 100644 marks.py delete mode 100644 student.py create mode 100644 student/student.py create mode 100644 student/student.pyc create mode 100644 student/studentlib.py create mode 100644 student_class.py create mode 100644 student_class.pyc create mode 100644 student_input.py create mode 100644 student_ops.py create mode 100644 student_ops.pyc create mode 100644 testing/__init__.py create mode 100644 testing/__init__.pyc create mode 100644 testing/matlib/__init__.py create mode 100644 testing/matlib/__init__.pyc create mode 100644 testing/matlib/math_ops.py create mode 100644 testing/matlib/math_ops.pyc create mode 100644 testing/matlib/series.py create mode 100644 testing/matlib/series.pyc create mode 100644 while.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..20af2f6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +// Place your settings in this file to overwrite default and user settings. +{ +} \ No newline at end of file diff --git a/api-repo.py b/api-repo.py index 6bdbbb2..27de0e5 100644 --- a/api-repo.py +++ b/api-repo.py @@ -35,6 +35,12 @@ # response contains the geoJSON object, # pretty print it to the console #print json.dumps(response, indent=4) +dic = {} +dic = response + +for k,v in dic.iteritems(): + print str(k) + ':' + str(v) + if response['login'] != None: print "+++++++++++++++++++++++++++++++++++++++++" print "My master's name is "+response['login'] diff --git a/books/author.py b/books/author.py new file mode 100644 index 0000000..b4527dc --- /dev/null +++ b/books/author.py @@ -0,0 +1,11 @@ +class Author: + count = 0 + + def __init__(self, name, gender, rating): + self.name = name + self.gender = gender + self.rating = rating + Author.count += 1 + + def get_details(self): + return 'Name: {0}, Gender: {1}, Rating: {2}'.format(self.name, self.gender, self.rating) \ No newline at end of file diff --git a/books/author.pyc b/books/author.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ffef26c2faa358f837003984e9013eb2c9b0f0e1 GIT binary patch literal 926 zcmcIixlY4C5FOh|#35=Libymm5DPR&2q7+sF2y2>xLFx{33g&T@@|9>p#t%%d;mYd zn=yw(9c<5dW{)@X-fr}RI1MEIY=+$LOxFQP1p=%|z6WzuW#J~y}EAEiK9&o7~Mk(X5@yG?t?ZPbrS`Zlop#(@H z2}1G_b&3w79)<>gLQf&K40G;a(1r7iS0$yDKF7AoY$IWl_`Dix%#!DYX+5ue%ZRr) zJH6A4q8U(gM*~>v9FtQw&Nfa>62MHYx~$WAX)Ev4IQOcu53{B&luxQMc~p0GGqIVv zt?P+XiHNm3d-N-SF($8aZ_qx9@&E;^@}^v!jb}uSEd=0NKnkKlWGO_GBBGb*o4eb_ zvLP5B^`G{hcluYt8Oc5pEv%6oJpY~^x+@d^m#vUzWtPu-9jIgLO=f+PPu&_)$1+pU zo>{94pPDhAXN@WAY(7P*Sq;s1PV=hY-XvPm!N{#({*DXvf?l}V8@8oH6%77UWw{c^ LE!h+4fNOmMsxHC> literal 0 HcmV?d00001 diff --git a/books/book.py b/books/book.py new file mode 100644 index 0000000..617cc80 --- /dev/null +++ b/books/book.py @@ -0,0 +1,23 @@ +class Book: + def __init__(self, title, pages, price, authors=None): + self.title = title + self.pages = pages + self.price = price + self.authors = authors + + def has_authors(self): + if self.authors: + return True + else: + return False + + def get_details(self): + details = '' + details = 'Title: {0}\nPages: {1}\nPrice: {2}'.format(self.title, self.pages, self.price) + if self.has_authors(): + for auth in self.authors: + details = details + '\n' + auth.get_details() + + return details + + diff --git a/books/book.pyc b/books/book.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c42f38379c4d6c079f74d78924df4d9966ff7a1b GIT binary patch literal 1237 zcmcIi!EVz)5S_IXLrjXephzI0a6vv{;22e?f{LSs+#*yXv@-EFb>i5;yAf1vPObP= zK7b!!-Z(9Yb8tM9+1c^TyqV|!+6%*eU679!CMv^vAR@rNu=5E z#NeYZ1|NH3a7yB46bC0=OGx5MR~ZLumCuarthSsQcZYrX+MPA6jU*BXtf@{@q)1Uc z1^g6#w9qMgz*hXhn%2gPysT%Hi4U9UdTDBB<5}tA+I(BJ%{+E_z0A+!)23aRBL2d& zv7(=^&fQ&3qIFr9PHR-MaF80vZ;A$PL?-Z%9Sna?)b5c}bmVyMf5E-&Q`T_Yt~SND73z262ybp5<0=rw9l(U(8pRR(lID;T!`#bR>xTXWPI^r6TZj( zC*$$OOSZuPcE8$K%sGre28Z5xTg%-2OMwC32oD@E&y3TBad}zU2mocc!l$iQwt%VZ zc;e}htKDa@Fh~XJi5jX0>amwZXnsqpI$s*CUC17-mrb#*aKsvtrZy=eQ$d6*e_9l4 kC-hD^uMk-15U61=2$HT4#x2+XqpslJ?-0L6C5uLW1GXgm(*OVf literal 0 HcmV?d00001 diff --git a/books/run_library.py b/books/run_library.py new file mode 100644 index 0000000..c9c0fac --- /dev/null +++ b/books/run_library.py @@ -0,0 +1,16 @@ +from book import Book +from author import Author + +a1 = Author('abc', 'm', 5) +a2 = Author('jane', 'f', 4) + +b1 = Book('book1', 100, 400) +b2 = Book('book2', pages=700, price=900, authors=[a1, a2]) + +#print b1.has_authors() +print b1.get_details() +print '--------------' +print b2.get_details() +#print b2.has_authors() +print '--------------' +print Author.count \ No newline at end of file diff --git a/fibo.py b/fibo.py index d82d5c2..add60ac 100644 --- a/fibo.py +++ b/fibo.py @@ -1,4 +1,16 @@ -#Fibo series generator - -#line 1 -# line 2 +n = int(raw_input('enter n: ')) +a,b = 0,1 +print a +print b +'''i = 2 +while i <= n: + c = a + b + print c + a,b = b,c + i = i + 1''' +for i in range(2,n): + c = a + b + print c + a,b = b,c + + \ No newline at end of file diff --git a/hello.py b/hello.py index d668898..23bde08 100644 --- a/hello.py +++ b/hello.py @@ -1,18 +1,18 @@ # hello +if __name__ == '__main__': + print 'hello world' -print 'hello world' + #print 'Good Night' + #print 'Good Evening' -#print 'Good Night' -#print 'Good Evening' + msg = 'Good Night to all' + print msg -msg = 'Good Night to all' -print msg + #Call fibo module to print fibo series -#Call fibo module to print fibo series - -#new code added. -#another addition to master file only -# integration with feature 2 resolved the bug toooooo + #new code added. + #another addition to master file only + # integration with feature 2 resolved the bug toooooo diff --git a/hello.pyc b/hello.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c61e55a1d8c9f7029be20322f33e7fe1c8df83e GIT binary patch literal 255 zcmYLDOKJi^5UrVs5{y}Rf(&FcEBgRSa1k&oH^D{RG>u)3<8*gPSBrQ6&*9elS* C`Z~t| literal 0 HcmV?d00001 diff --git a/marks.py b/marks.py new file mode 100644 index 0000000..6659856 --- /dev/null +++ b/marks.py @@ -0,0 +1,9 @@ +marks = float(raw_input('enter marks: ')) +if marks >= 70: + print 'A' +elif marks >= 60: + print 'B' +elif marks >= 40: + print 'C' +else: + print 'Fail' \ No newline at end of file diff --git a/student.py b/student.py deleted file mode 100644 index cb38228..0000000 --- a/student.py +++ /dev/null @@ -1,2 +0,0 @@ -#student modulte deploying -#completed my feature \ No newline at end of file diff --git a/student/student.py b/student/student.py new file mode 100644 index 0000000..c6b11b2 --- /dev/null +++ b/student/student.py @@ -0,0 +1,17 @@ +class Student: + def __init__(self, name, gender, roll, marks): + self.name = name + self.gender = gender + self.roll = roll + self.marks = marks + + def get_grade(self): + marks = self.marks + if marks >= 70: + return 'A' + elif marks >= 60: + return 'B' + elif marks >= 40: + return 'C' + else: + return 'Fail' diff --git a/student/student.pyc b/student/student.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6a2fb130f92a2abcfad526f5594577394641d578 GIT binary patch literal 370 zcmcIfOAf*y5S?11#>BN(=t?eNj4`@(VdKJX2r1b3fto^NT&vgdA|A&J_@L?yB+Q$c zH^6(uuR;I$xNma$tQdKUutR{vj!8yzBf1i8GW0DN+xRh4B2u`|U{v3Z%-8giBuJI9PV zpQ>`toG@Bk*tV<=N;2Cx`sUH;vhr_wW7b>fM9W6WGhy^M;qcpW^S?= 70: + return 'A' + elif self.marks >= 60: + return 'B' + elif self.marks >= 40: + return 'C' + else: + return 'Fail' + + diff --git a/student_class.pyc b/student_class.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3b41b9614ea15f91de1762a8e8dd6ef02b20ead6 GIT binary patch literal 1402 zcmcIjJ#Q015S{z5gN*`66mC-?7l0A|NLc@nvqVV%l! zoa0+Kf|`c=%C%vCIstY8@$aFW$Sk1`oSvmyH#7K470KzFpL$}V%Xtr{C@JI;;>S>r zi9Cu}7^xaqW@=!Ws{xltWz67{m|G6BE!QseVJux+xh@dvHcb;4VO@4BKc=O)cg@1^ zykTfV5)Ahrk}r`(3xWEkfC@%ZFmI=~k{P zd}PSZo6`FacMstO{8(GJb+DGfJON1t`plUFg&8OVA7P*Y0p*L_Ci0ZX2n3F{KpKH; z4`d2NJ|~{#Pr$?Ji66imep4#2V)KRuY@D7%#u(6t?k^IQQ$v~#z{C)4moC`Kg|co) zgC`-9>{-~)!5hG=f5*atQyBZL4b#@Kgo7r0i~vlSlVv$dF9G~B=ktBe=-;X*-CMmp zu?&npp?6Z{GTlNwg+58umuYnb;ZT#7Nqq$!Smb$qwlgnk_C(Q39pWpn80**3RZb4n zIt~+=SaxOQUSZ*>Bzc|WJ4weJzU{axV>Ynk)~+|zedDY(++bLsp+7?xEa?yRziyqO hTN0wTt)C3~gKUsZVl*X+8x9m)IXH_|f7T=z>^E=Y9UK4v literal 0 HcmV?d00001 diff --git a/student_input.py b/student_input.py new file mode 100644 index 0000000..ba48ba0 --- /dev/null +++ b/student_input.py @@ -0,0 +1,28 @@ +'''from student_ops import get_details, get_grade + + +name = str(raw_input('Enter Student Name: ')) +gender = str(raw_input('Enter Gender: ')) +roll = input('Enter Roll: ') +marks = input('Enter Marks: ') + +print get_details(name, gender, roll) +print name + ' got a grade ' + get_grade(marks) +''' + +from student_class import Student + +s1 = Student('Arun', 'm', 45, 89) +s2 = Student('Karan', 'm', 100, 46) + +print s1.get_detail() +print s2.get_detail() + + +print s1.get_grade() +print s2.get_grade() + +tufle = s1.get_name_roll() + +for i in tufle: + print i \ No newline at end of file diff --git a/student_ops.py b/student_ops.py new file mode 100644 index 0000000..3c7ea81 --- /dev/null +++ b/student_ops.py @@ -0,0 +1,14 @@ +def get_details(name, gender, roll): + return 'Name: ' + str(name) + '\nGender: ' + str(gender) + '\nRoll: ' + str(roll) + +def get_grade(marks): + if marks >= 70: + return 'A' + elif marks >= 60: + return 'B' + elif marks >= 40: + return 'C' + else: + return 'Fail' + + diff --git a/student_ops.pyc b/student_ops.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb78ca0e66ef99570b0c3e420df90ab4785b4e92 GIT binary patch literal 706 zcmb_ZO-lnY5S?^e`{4(k?6t>5!FZHX#9FDhf?Yi5r7WActov1xDN^vJ_=o)i&dgf; z16`Q6?*xt+DaI9F=N9y8x$bG z2f(L-A>|HPsYV5jYKe-%Hl;880b^X+@yPdy4jyb}tRvNBwXBO`JPNrcBgu8vfD7p+Ce{V#cUIUx8iLfD=v>CwrPvNoH--f+|M2L0d{1Cf%~ literal 0 HcmV?d00001 diff --git a/testing/__init__.py b/testing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/testing/__init__.pyc b/testing/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..06e008e97fb07ddd937979f74acb874c1930cb5a GIT binary patch literal 157 zcmZSn%*%CZPHSW`0~9az*Q}arS_0uy;^z%~73ySiy^h*-+auX}{)AEb5Q&aRyQj1G~s`caJGxIV_ b;^XxSDoZ$kM%m=%rz*Q}arS_0uy;^z%~73ySiy^h*-+auX}{)AEb5Q&aRyQj1G~s`YadOL8)k i^yA|*^D;}~*lOekys literal 0 HcmV?d00001 diff --git a/testing/matlib/math_ops.py b/testing/matlib/math_ops.py new file mode 100644 index 0000000..8b86d45 --- /dev/null +++ b/testing/matlib/math_ops.py @@ -0,0 +1,5 @@ +def evenodd(n): + if n % 2 == 0: + return True + else: + return False \ No newline at end of file diff --git a/testing/matlib/math_ops.pyc b/testing/matlib/math_ops.pyc new file mode 100644 index 0000000000000000000000000000000000000000..17a0f5e172871f50e340735de6bc4ac243826301 GIT binary patch literal 398 zcmcIf%Sr?>5bT*{WQ<;3vXE$G;tA>78fqDVNImi%w5IsT^R97WVnslF#HkUv=1-)m-i7BZq zDIAj!)q)oE*VP1urA>YdP#z;wsQWOo>_J@XE^?KoqKU{=Aj%YPq0~d<5LK(K+jOk1 zd^7g!B&v-S<@jv~eyc>gUhmY}hn9^JjsmypwRHA5m6s12bjpO?7YFJkbfUU f#ZfUWmpQ^+%KMk#zhWHXmGj=4vExO~kz)J+zrR^0 literal 0 HcmV?d00001 diff --git a/testing/matlib/series.py b/testing/matlib/series.py new file mode 100644 index 0000000..2d26f69 --- /dev/null +++ b/testing/matlib/series.py @@ -0,0 +1,16 @@ +def fibo(n): + series = '' + a,b = 0,1 + series = series + str(a) + '\t' + str(b) + '\t' + for i in range(2,n): + c = a + b + series = series + str(c) + '\t' + a,b = b,c + return(series) + +def even(n): + series = '' + for i in range(0, n+1,2): + series = series + str(i) + '\t' + + return(series) \ No newline at end of file diff --git a/testing/matlib/series.pyc b/testing/matlib/series.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8d1e8c1417491d7858ced68718c9b8ba4568ccb GIT binary patch literal 847 zcmcIi%}&BV82q-SD5!}h28;=b@zj$WJsUO3&4fdVF&aG-x{wOA&|MS~dO{z;C-nuK zZ)=bjpy^KcXLi5YnYurF)sye9r!M_H0^b`nT?0f!pG42-2-^`9In?%DEOnV!Mk}G+ zq3Ij|UJg>3UL4Bty0j2vh!zel1=XVx)p_KuMqtlw$zYF13!GM8*1p0?>sr801}x0}3jvD= ySVh1QY}ga^u96*;(c1v_q#=%+R-vncnV<^z*RYvzxc22Jjiy6&WdmYID%D?Tu%Yz; literal 0 HcmV?d00001 diff --git a/while.py b/while.py new file mode 100644 index 0000000..7c7b140 --- /dev/null +++ b/while.py @@ -0,0 +1,34 @@ +#import series +from testing.matlib.series import fibo, even +import testing.matlib.math_ops as mo +import math + +print math.pi + +while True: + print '1. Fibo Series' + print '2. Even Series' + print '3. Even or Odd' + print '4. Exit' + + choice = int(raw_input('What is your choice: ')) + if choice != 4: + n = int(raw_input('Enter the value of N: ')) + + if choice == 1: + print fibo(n) + elif choice == 2: + print even(n) + elif choice == 3: + if mo.evenodd(n): + print 'is even' + else: + print 'is odd' + else: + break + + +#add python path to the modules + + + \ No newline at end of file