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
MONTHS = ['January', 'February', 'Match', 'April', 'May', 'June', | |
'July', 'August', 'September', 'October', 'November', 'December'] | |
def date_convert(s): | |
y = s[:4] | |
m = int(s[5:-3]) | |
d = s[8:] | |
month_name = MONTHS[m-1] | |
result= month_name + ' ' + d +' '+ y | |
return result |
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
print('Miles | Km') | |
for i in range(1,100,10): | |
print('{} | {}'.format(i,i*1.609)) |
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
print('Pounds | Kg') | |
for i in range(1,100,10): | |
print('{} | {}'.format(i,i*0.453)) |
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
t1 = input('Welcome to Computer Tutor!\n Please enter the first time:') | |
t2 = input('Please enter thr second time:') | |
print(int(t2[:2])-int(t1[:2]),'hours', int(t2[2:])-int(t1[2:]),'minutes') |
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 dollartorupee(amt,exc): #Void | |
print('Rs', amt*exc) | |
def dollartorupee2(amt,exc): #Non-Void | |
print('Rs', amt*exc) | |
return amt*exc | |
dollartorupee(100,7) | |
print('Rs', dollartorupee2(500,7)) |
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 volume(l=1,b=1,h=1): | |
return l*b*h | |
v1=volume() | |
v2=volume(10,5,2) | |
v3=volume(b=8) | |
v4=volume(5,7) | |
print(v1) | |
print(v2) | |
print(v3) |
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 cube(x=2): | |
print('Cube of',x, 'is', x**3) | |
def equal(x,y): | |
return x==y | |
cube() | |
cube(5) | |
print(equal('a','b')) | |
print(equal('s','s')) |
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 equ_len(x,y): | |
return len(x)==len(y) | |
a=input('Enter first string:') | |
b=input('Enter second string:') | |
print('Length of', a, 'is equal to length of',b,'is', equ_len(a,b)) |
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 nthroot(x,n=2): | |
return round(x**(1/n),2) | |
print("Nth root of",10, 'for n=3 is',nthroot(10,3)) | |
print("Square root of",30,"is", nthroot(30)) |
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
from random import randint | |
def random(x,y): | |
return randint(x,y) | |
print("Three random numbers are: ", random(10,50),random(2,10),random(500,600)) |