Anda di halaman 1dari 4

# -*- coding: utf-8 -*-

"""
Created on Tue Jan 16 17:43:12 2018

@author: ltyle_000
"""

def multi_table(b, c):


for i in range(1,c):
print('{0} * {1} = {2}'.format(b, i, b*i))

if __name__=='__main__':

while True:
b = int(input('Enter the integer:'))
c = int(input('Enter the mulple integer'))
multi_table(b, c)

answer = input('Do you want to exit? (y) for yes')


if answer == 'y':
break

# -*- coding: utf-8 -*-


"""
Created on Sat Jan 20 17:10:42 2018

@author: ltyle
"""

#Fraction Operations

from fractions import Fraction

def add(a,b):
print('Result of Addition: {0}'.format(a+b))

def subtract(a,b):
print('Result of Subtraction: {0}'.format(a-b))

def multiply(a,b):
print('Result of Subtraction: {0}'.format(a*b))

def divide(a,b):
print('Result of Subtraction: {0}'.format(a/b))

if __name__=='__main__':
a = Fraction(input('Enter first fraction: '))
b = Fraction(input('Enter second Fraction: '))

op = input('Operation to perform - Add, Subtract, Divide, Multiply: ')

if op =='Add':
add(a,b)

if op =='Subtract':
subtract(a,b)

if op =='Multiply':
multiply(a,b)

if op =='Divide':
divide(a,b)

# -*- coding: utf-8 -*-


"""
Created on Tue Jan 16 18:05:19 2018

@author: ltyle_000
"""

#Unit Converter: Miles and Kilometers

def print_menu():
print('1. Kilometers to Miles')
print('2. Miles to Kilometers')
print('3. Kilograms to pounds')
print('4. Pounds to Kilograms')
print('5. Celsius to Farienhit')
print('6. Farienhit to Celsius')

def km_miles():
km = float(input('Enter distance in kilometers:'))
miles = km/1.609

print('Distance in Miles: {0}'.format(miles))


def miles_km():
miles = float(input('Enter distance in miles: '))
km = miles * 1.609

print('Distance in kilometers: {0}'.format(km))

def kg_pd():
kg = float(input('Enter wieght in kilograms'))
pd = kg / 0.45359237

print('Wieght in pounds is {0}'.format(pd))

def pd_kg():
pd = float(input('Enter wieght in pounds'))
kg = pd * 0.45359237

print('Wieght in kilograms is {0}'.format(kg))

def cel_far():
cel = float(input('Enter the temp in Celsius'))
far = cel * (9/5) + 32

print('The temp in Farinhiate {0}'.format(far))

def far_cel():
far = float(input('Enter the temp in Farienhiet'))
cel = (far - 32)*(5/9)

print('The temp in Celsius is {0}'.format(cel))

if __name__ == '__main__':
print_menu()
choice = input('Which conversion would you like to do?:')
if choice == '1':
km_miles()

if choice =='2':
miles_km()

if choice =='3':
kg_pd()

if choice =='4':
pd_kg()

if choice =='5':
cel_far()
if choice =='6':
far_cel()