Ejemplo n.º 1
0
import converters #Import entire converters module
from converters import kg_to_lbs
#Hit control and space after import keyword to see all the functions from module. e.g. converters

kg_to_lbs(70) #importing specific function from converters module

print(converters.kg_to_lbs(70)) #using method from importing the entire converters module
Ejemplo n.º 2
0
import converters  # Method 1 of using Modules
from converters import kg_to_lbs  # Method 2 of using Modules

print(converters.kg_to_lbs(100))  # Method 1

print(kg_to_lbs(100))  # Method 2
Ejemplo n.º 3
0
import converters

print(converters.kg_to_lbs(70))
print(converters.lbs_to_kg(200))


Ejemplo n.º 4
0
import converters
from converters import kg_to_lbs

kg_to_lbs(100)
print(converters.kg_to_lbs(45))
Ejemplo n.º 5
0
# from converters import lbs_to_kg -
import converters
from converters import kg_to_lbs
from list_operators import find_max

resultado_1 = converters.lbs_to_kg(150)
# utilizando from ... poderia chamar apenas lbs_to_kg
print(resultado_1)

resultado_2 = kg_to_lbs(67.5)
print(resultado_2)

lista = [4, 6, 15, 10, 3, 32]
maximo_proprio = find_max(lista)
maximo_linguagem = max(lista) # cuidado para não utilizar nomes já existentes na linguagem (Roxo)
print(maximo_proprio)
print(maximo_linguagem)
import converters
print((converters.kg_to_lbs(50)))


def lbs_to_kg(weight):
    return weight * 0.45


def kg_to_lbs(weight):
    return weight / 0.45


import converters
from converters import kg_to_lbs
print(kg_to_lbs(34))

from utils import find_max
numbers = [1, 4, 778, 9, 2, 3, 5]
maximum = find_max(numbers)
print(maximum)


def find_max(numbers):
    maximum = numbers[0]
    for number in numbers:
        if number > maximum:
            maximum = number
    return maximum
Ejemplo n.º 7
0
#import converters
from converters import kg_to_lbs

print(kg_to_lbs(100))

#print(converters.kg_to_lbs(70))





Ejemplo n.º 8
0
import math
import converters
from converters import kg_to_lbs
from converters import lbs_to_kg
from utils import find_max

weight = int(input("Your Weight: "))
unit = input("L(bs) or K(g): ")
convert = 0

if unit.lower() == 'k':
    convert = converters.kg_to_lbs(weight)
    print(f'Your Weight is {convert} Lbs')
elif unit.lower() == 'l':
    convert = lbs_to_kg(weight)
    print(f'Your Weight is {convert} kg')
else:
    print('something went wrong')

my_list = [4, 32, 100, 112, 21, 43]

print(find_max(my_list))
Ejemplo n.º 9
0
import converters
from converters import find_max

weight_kg = converters.lbs_to_kg(89)
print(weight_kg)

weight_lbs = converters.kg_to_lbs(89)
print(weight_lbs)

numbers = [10, 20, 1, 2, 30, 45]
print(find_max(numbers))
Ejemplo n.º 10
0
import converters  #you can import entire module       2 ways
from converters import lbs_to_kg  #u can use method directly
import utils
from utils import find_max

kg20 = converters.kg_to_lbs(20)

print(kg20)

lbs20 = lbs_to_kg(70)

print(lbs20)

num = [34, 33, 55, 77, 88, 33, 22]
num2 = 4

utils.find_max(num)
utils.find_max(num2)
find_max(num)
Ejemplo n.º 11
0
#----------------------------End of the Tutorial ---------------------------------#
###
#
#
# Modules
# Each file called module
#
#
# to access
# import converters =>  converters.kg_to_lbs(2)
#
#from converters import kg_to_lbs => kg_to_lbs(2)
# ##
import converters
from converters import kg_to_lbs
print(kg_to_lbs(20))
print(converters.kg_to_lbs(2))

###
#
#
# Execise
#
# ##

from utils import find_max

print(find_max())

exit()
Ejemplo n.º 12
0

class AA:
    def show(self):
        print('in AA')


class BB(AA):
    def show(self):
        print('in BB')


a = BB()
a.show()

print(converters.kg_to_lbs(68))
# from converters import kg_to_lbs
# done to directly access the function without any . operator needed

seq = [1, 2, 3, 4, 5]
# maps function to the list with the lambda expression
print(list(map(lambda var: var * 2, seq)))
# which is analogous to anonymous functions

print(list(filter(lambda num: num % 2 == 0, seq)))

tweet = 'Go Sports! #Sports'
# splits the tweet and gets anything after the pound sign
print(tweet.split('#')[1])
print('x' in [1, 2, 3])
x = [(1, 2), (3, 4), (5, 6)]
Ejemplo n.º 13
0
from converters import kg_to_lbs

print(kg_to_lbs(200))
Ejemplo n.º 14
0
import converters

from converters import kg_to_lbs

print(f"{converters.kg_to_lbs(80)} lbs")

print(f"{converters.lbs_to_kg(200)} kgr")

# No converters prefix, because I used the from word and imported specifically this function
print(kg_to_lbs(120)) 
Ejemplo n.º 15
0
import converters  # 导入体重转换模块
import utils  # 导入寻找最大的数字模块
from converters import lbs_to_kg  # 导入模块的方法

k_to_l = converters.kg_to_lbs(70)
print(k_to_l)
l_to_k = lbs_to_kg(120)
print(l_to_k)

numbers = [10, 3, 6, 2, 20]
max_number = utils.find_max(numbers)
print(max_number)
Ejemplo n.º 16
0
import converters

from converters import kg_to_lbs

print(kg_to_lbs(73))

#packages

#import ecommerce.shipping
#from ecommerce.shipping import calc_shipping
from ecommerce import shipping

shipping.calc_shipping()
Ejemplo n.º 17
0
import math
import converters
from converters import lbs_to_kg

print("This's my weight in kg {} ".format(lbs_to_kg(210)))

print("This's my weight in lbs {} ".format(converters.kg_to_lbs(92)))

info = 'Python is an interpreted, high-level, general-purpose programming language.'
print(info)
print(info[-1])
print(info[0:6])
print(info[-9:-1])

birth_year = input("Birth year: ")
print(type(birth_year))
age = 2019 - int(birth_year)
print(age)
print(type(age))

lbs_weight = input("Weight (Lbs): ")
kg_weight = 0.45 * int(lbs_weight)
print(kg_weight)
print("things")
x = -2.9
print(abs(x))
Ejemplo n.º 18
0
import converters
from converters import lbs_to_kg
import utils

print(converters.kg_to_lbs(56))
print(lbs_to_kg(56))

numbers = [10, 20, 5, 50, 7, 60, 55, 56]

print(utils.find_max(numbers))
print(max(numbers))  #inbuilt function
Ejemplo n.º 19
0
import converters
from converters import kg_to_lbs
from utils import find_max
import ecommerce.shipping  # name of packcage.module
# or for easier code
from ecommerce.shipping import calculate_shipping
# if you have multiple function from a module
from ecommerce import shipping

kg_to_lbs(70)  # when import a method then don't need to prefix it
converters.kg_to_lbs(70)

# Exercise
# create a function to find max in converters.py

numbers = [10, 3, 6, 2]

print(find_max(numbers))

print("----------------------")

# packages

ecommerce.shipping.calculate_shipping()
# instead of above we can use
calculate_shipping()
calculate_shipping()

# since we imported from shipping
shipping.calculate_shipping()
Ejemplo n.º 20
0
import converters
# from converters import kg_to_lbs
# lbs = kg_to_lbs(100)

print("LBS TO KG ->", converters.lbs_to_kg(50))
print("KG TO LBS =>", converters.kg_to_lbs(70))
Ejemplo n.º 21
0
import converters
from converters import kg_to_lbs

kg_to_lbs(200)



converters.kg_to_lbs(70)
Ejemplo n.º 22
0
spike.bark()

# MODULES

# A module in python is basically a file with python code
# it is used to break codes in different files instead of writing all the
# codes in one file
# this increases modularity and helps to reuse them
# Moreover it allows to address accidentally occurred errors very efficiently

# Again there are two ways to import a module

# 1st way
from converters import kg_to_lbs

print(kg_to_lbs(65))

#2nd way
import converters
print(converters.kg_to_lbs(67))

# So, to import a specific function of a module we use "from ... import ...
# and by this process we can use the imported function as it were defined
# in this python file

# If we use "import ...", all the functions of that module is imported
# but to to access any function, we need to prefix that function by the
# moudule name and the dot(.) operator

# Exercise for Modules
import utils
Ejemplo n.º 23
0
class Cat(Mammal):
    def be_annoying(self):
        print('annoying', self.legs)


cat1 = Cat(4)
cat1.be_annoying()

dog1 = Dog(3)
dog1.bark()
dog1.walk()

import converters
from converters import kg_to_lbs

kg_to_lbs(100)

print("kg to lbs ", converters.kg_to_lbs(70))


class Person:
    def __init__(self, name, lname):
        self.name = name
        self.lname = lname

    def talk(self):
        print(f'Hi, im {self.name, self.lname}')


john = Person("jayant", "kumar")
john.talk()
Ejemplo n.º 24
0
import converters
from converters import kg_to_lbs

kg_to_lbs(100)
Ejemplo n.º 25
0
# import from converters.py
import converters
from converters import kg_to_lbs

print(kg_to_lbs(70))

Ejemplo n.º 26
0
#modules

import converters
from converters import kg_to_lbs

kg_to_lbs(100)

print(converters.kg_to_lbs(">")))

#converters#
# def lbs_to_kg(weight):
#     return weight * 0.45
#
#
# def kg_to_lbs(weight):
#     return weight / 0.45

Ejemplo n.º 27
0
# This file starts from 3:20:04 till 3:25:28
# This files is a based on 11th.py
# This file is about modules
#We could either import the whole module or we could import specific functions from that module

import converters
your_Weight = converters.lbs_to_kg(175)
print(your_Weight)  #78.75

from converters import lbs_to_kg
from converters import kg_to_lbs
my_Weight = lbs_to_kg(180)
print(my_Weight)  #81.0
print(kg_to_lbs(my_Weight))  #180.0
Ejemplo n.º 28
0
import converters
from converters import kg_to_lbs


print(converters.lbs_to_kg(10))
print(kg_to_lbs(4.5))
Ejemplo n.º 29
0
import converters

print(converters.kg_to_lbs(100))
import converters
from converters import kg_to_lbs
import utils
from utils import find_max
import ecommerce.shipping
from ecommerce.shipping import calc_shipping, calc_tax
from ecommerce import shipping

kg_to_lbs(100)

print(converters.kg_to_lbs(70))  # 155.55555555555554 from line 2
print(converters.lbs_to_kg(120))  # 54.0 from line 2

# utils.find_max()       from line 3
numbers = [10, 3, 6, 2, 5]
maximum = find_max(numbers)
print(maximum)  # 10 from line 4

ecommerce.shipping.calc_shipping()  # calc_shipping from line 5
ecommerce.shipping.calc_tax()  # calc_tax from line 5
calc_shipping()  # calc_shipping from line 6
calc_tax()  # calc_tax from line 6
shipping.calc_tax()  # calc_tax from line 7
shipping.calc_shipping()  # calc_shipping from line 7
shipping.cal_order()  # calc_order from line 7