Python Forum
The of ( : ) what does it do?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The of ( : ) what does it do?
#1
Hi,

I dont understand this part of the code.
The : between protein and Nutrient in protein: Nutrient = Nutrient(name="Protein") what does it do?

Thank you


from ingredient import *
from nutrition_rule import *
from typing import List

protein: Nutrient = Nutrient(name="Protein")
fat: Nutrient = Nutrient(name="Fat")
fibre: Nutrient = Nutrient(name="Fibre")
salt: Nutrient = Nutrient(name="Salt")
Nutrients: List[Item] = [protein, fat, fibre, salt]

for n in Nutrients:
    print(n)

NutrientRules: List[NutrientRule] = [NutrientRule(protein, op=OPERATOR_MIN, value=8.0),
                                     NutrientRule(fat, OPERATOR_MIN, 6.0),
                                     NutrientRule(fibre, OPERATOR_MAX, 2.0),
                                     NutrientRule(salt, OPERATOR_MAX, 0.4)]

for r in NutrientRules:
    print(r)

Ingredients: List[Ingredient] = [
    Ingredient(name="CHICKEN", cost=0.013,
               nutrient_percents={protein.name: 0.1, fat.name: 0.08, fibre.name: 0.001, salt.name: 0.002}),
    Ingredient("BEEF", 0.008, {protein.name: 0.2, fat.name: 0.1, fibre.name: 0.005, salt.name: 0.005}),
    Ingredient("MUTTON", 0.010, {protein.name: 0.15, fat.name: 0.11, fibre.name: 0.003, salt.name: 0.007}),
    Ingredient("RICE", 0.002, {protein.name: 0, fat.name: 0.01, fibre.name: 0.1, salt.name: 0.002}),
    Ingredient("WHEAT", 0.005, {protein.name: 0.04, fat.name: 0.01, fibre.name: 0.15, salt.name: 0.008}),
    Ingredient("GEL", 0.001, {protein.name: 0, fat.name: 0, fibre.name: 0, salt.name: 0})
]

for i in Ingredients:
    print(i)
Reply


Messages In This Thread
The of ( : ) what does it do? - by Frankduc - Jul-30-2022, 02:44 PM
RE: The of ( : ) what does it do? - by deanhystad - Jul-30-2022, 05:11 PM
RE: The of ( : ) what does it do? - by Frankduc - Jul-30-2022, 05:48 PM
RE: The of ( : ) what does it do? - by deanhystad - Jul-30-2022, 09:06 PM
RE: The of ( : ) what does it do? - by mHosseinDS86 - Jul-31-2022, 09:33 AM
RE: The of ( : ) what does it do? - by ndc85430 - Jul-31-2022, 10:16 AM
RE: The of ( : ) what does it do? - by Frankduc - Jul-31-2022, 11:48 AM
RE: The of ( : ) what does it do? - by DeaD_EyE - Jul-31-2022, 03:31 PM
RE: The of ( : ) what does it do? - by Frankduc - Jul-31-2022, 03:57 PM
RE: The of ( : ) what does it do? - by deanhystad - Jul-31-2022, 05:22 PM
RE: The of ( : ) what does it do? - by Frankduc - Jul-31-2022, 06:35 PM
RE: The of ( : ) what does it do? - by deanhystad - Aug-01-2022, 03:50 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020