This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Conversion | |
| __init__.py | |
| Length | |
| __init__.py | |
| Lengthconversion.py | |
| Mass | |
| __init__.py | |
| Massconversion.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def miletokm(mile): | |
| return mile*1.609 | |
| def kmtomile(km): | |
| return km*0.62 | |
| def feettoinches(feet): | |
| return feet*12 | |
| def inchestofeet(inch): | |
| return inch*0.0833 | |
| #Constants | |
| MILES= '1.609344 KM' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def kgtotonne(Kg): | |
| return Kg*0.001 | |
| def tonnetoKg(tonne): | |
| return tonne**1000 | |
| def kgtopound(Kg): | |
| return Kg*2.20462 | |
| def poundtokg(pound): | |
| return pound*0.453592 | |
| #Constants |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bubble_sort(k): | |
| for i in range(1,len(k)): | |
| for j in range (len(k)-1): | |
| if k[j]>k[j+1]: | |
| k[j],k[j+1]=k[j+1],k[j] | |
| return k | |
| dict = {'c':1,'f':22,'a':13,'d':4,'e':5,'h':8} | |
| k=list(dict.values()) | |
| print(bubble_sort(k)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bubble_sort(k): | |
| for i in range(1,len(k)): | |
| for j in range (len(k)-1): | |
| if k[j]>k[j+1]: | |
| k[j],k[j+1]=k[j+1],k[j] | |
| return k | |
| dict = {'c':1,'f':22,'a':13,'d':4,'e':5,'h':8} | |
| k=list(dict.keys()) | |
| print(bubble_sort(k)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add_dict(dict1, dict2): | |
| return dict(list(dict1.items()) + list(dict2.items())) | |
| dic1 = {'a':1, 'b':2, 'c':3} | |
| dic2 = {'c':4, 'd':5, 'e':6} | |
| print(add_dict(dic1, dic2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mo={'January':31,'February':28,'March':31,'April':30,'May':31,'June':30, | |
| 'July':31,'August':31,'September':30,'October':30,'November':30, | |
| 'December':31} | |
| m=input("\nEnter a month:") | |
| print('\nNumber of days in', m,'is',mo.get(m.strip(),'Enter again:')) | |
| print("\nAll months in sorted order are as follows: ",sorted(mo)) | |
| for i in mo: | |
| if mo[i]==31: | |
| print ('\nMonth having 31 day is:',i, end=' ') | |
| print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_fibonacci(n): | |
| fib = [] | |
| a, b = 0, 1 | |
| for i in range(n): | |
| a, b = b, a+b | |
| fib.append(a) | |
| return tuple(fib) | |
| make_fibonacci(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| first = 'Jimmy' | |
| second = 'Johny' | |
| print('Before Swapping',first, second) # Jimmy Johny | |
| first, second = second, first # swaps the variables | |
| print("After swapping:", first, second) # Johny Jimmy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| l=[i for i in range(1,101) if i%3==0 or i%5==0] | |
| print(l) |
NewerOlder