{{ message }}

Instantly share code, notes, and snippets.

# computer-tutor

Created Apr 28, 2020
View Chap4Q3.py
This file contains 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
Created Apr 28, 2020
View Chap4Q2.py
This file contains 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'
Created Apr 28, 2020
View Chap4Q1.py
This file contains 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
Created Apr 28, 2020
View Chap2Q12.py
This file contains 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))
Created Apr 28, 2020
View Chap2Q11.py
This file contains 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))
Last active May 8, 2021
View Chap2Q10.py
This file contains 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))
Last active May 8, 2021
View Chap2Q9.py
This file contains 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()
Created Apr 28, 2020
View Chap2Q8.py
This file contains 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)
Last active May 8, 2021
View Chap2Q7.py
This file contains 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
Created Apr 28, 2020
View Chap2Q6.py
This file contains 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)