예제 #1
0
def print_melon(melons):
    for melon_type, melon_data in melons.items():
        # items returns a list of tuples, making it easy to unpack multiple variables at once
        print melon_type
        for description, value in melon_data.items():
            print "%s: %r" % (description, value)
        print "\n"
def print_melon(melons):
    """Print each melon with corresponding attribute information."""

    for melon_name, attributes in melons.items():
        print(melon_name.upper())
        for attribute, value in attributes.items():
            print(f'{attribute}: {value}')
예제 #3
0
def print_melon(melons):
    """Print each melon with corresponding attribute information."""
    for malon_name, attr in melons.items():
        print(malon_name.upper())

        for key, val in attr.items():
            print(f" {key}: {val}")
def print_melon(melons):
    """Print each melon with corresponding attribute information."""

    for melon, attributes in melons.items():
        print("{}" .format(melon))
        for attribute in attributes:
            print("{}: {}" .format(attribute, attributes[attribute]))
예제 #5
0
def print_melons(melons):
    """Print each melon with corresponding attribute information."""

    for melon, attribute in melons.items():
        print('MELON TYPE:', melon)
        for attribute, value in attribute.items():
            print(attribute, value) 
예제 #6
0
def print_all_melons(melons):
    """Print each melon with corresponding attribute information."""

    for melon, attributes in melons.items():
        print(melon.upper())
        for attribute, value in attributes.items():
            print(f"{attribute}: {value}")
        print('===================================')
예제 #7
0
def print_all_melon(melons):
    """ Print each melon and its associated characteristics. """

    for melon, attributes in melons.items():
        print melon.upper()
        for attribute, value in attributes.items():
            print "  {}: {}".format(attribute, value)
        print
예제 #8
0
def print_all_melons(melons):
    """Print each melon with corresponding data"""

    for melon_name, attribute in melons.items():
        print(melon_name.upper())

        for attribute, value in attribute.items():
            print(f'\t{attribute}:{value}')
예제 #9
0
def print_melons(melons):
    """Print melons."""

    for melon, parametrs in melons.items():
        print melon.upper()
        for parametr, value in parametrs.items():
            print "{} : {}".format(parametr, value)
        print "\n"
def print_melons(melons):
    """Print each melon with corresponding attribute information."""

    for name, attributes in melons.items():
        print(name.upper())

        for attributes, value in attributes.items():
            print(f"     {attributes}: {value}")
예제 #11
0
def print_melons(melons):
    """Print each melon with corresponding attribute information."""
    #For Melon (Keys) names in Dictionary, print the Melon name sin uppercase
    for melon_names, attributes in melons.items():
        print(melon_names.upper())
        # For the various Values in attributes in Melon dictionary
        #Print attribut:Value
        for attribute, value in attributes.items():
            print(f"{attribute}: {value}")
예제 #12
0
def print_melon(melons):
    """Print each melon with corresponding attribute information."""

    for name, attr in melons.items():
        print(name.upper())

        for att, value in attr.items():
            print(f'{att} : {value}')
        print('--------------------')
def print_melon(melons):
    """Print each melon with corresponding attribute information."""

    for melon, characteristics in melons.items():
        print(melon.upper())

        for characteristic, value in characteristics.items():
            print(f"{characteristic}: {value}")

        print("------------------------")
예제 #14
0
def print_melon(melon):
    """Print each melon with corresponding attribute information."""

    for melon_name, info in melons.items():
        print(melon_name.upper())

        for info, value in info.items():
            print(f"{info}: {value}")

        print('===================================')
예제 #15
0
def print_all_melons(melons):
    """Print every melon and corresponding attributes"""

    for melon_name, attributes in melons.items():
        print(melon_name)

        for attribute, value in attributes.items():
            print(f'{attribute}: {value}')

        print('==================')
예제 #16
0
def print_melons(melons):
    """Print each melon with corresponding attribute information."""

    #Capitalizes melon name and assigns variables in dict
    for melon_name, attributes in melons.items():
        print(melon_name.upper())
        
        #Assigns variables in nested dict
        for attribute, value in attributes.items():
            print(f'{attribute}: {value}')
        print('------------------')
def print_melons(melons):
    """Print each melon with corresponding attribute information."""

    for melon_name, melon_attributes in melons.items():

        print("")
        print(f'{melon_name.upper()}') #Prints melon name

        for melon_attribute, melon_value in melon_attributes.items():

            print(f'{melon_attribute}: {melon_value}') #Prints melon attributes
예제 #18
0
def print_melon(melon_name):
    """Print each melon with corresponding attribute information."""

    # have_or_have_not = "have"

    # iterates through each melon name
    for melon, attributes in melons.items():
        print(melon.upper())

        # iterates through attributes of each melon
        for attribute, value in attributes.items():
            print(f"{attribute}: {value}")

        print()
예제 #19
0
def print_all_melons(melons):
    """Print each melon with corresponding attribute information"""

    for melon_name, attributes in melons.items(
    ):  #pulls out the first key, and
        #the dictionary associated to it and naming that attributes
        print(melon_name.upper())  #print melon name in caps

        for attribute, value in attributes.items(
        ):  #loop through the attribute
            #dictionary and pulls attribute keys and the values for them
            print(f'{attribute}: {value}')

        print('==================================')
def print_out_melon_info(melons):
    """Print out all the melons in our inventory."""

    additional_info = (raw_input("Do you have additional things to track? ")).lower()
    if additional_info == "yes":
        melon = raw_input("Which melon is it for? ")
        characteristic = raw_input("What is the new characteristic? ")
        additional_value = raw_input("What is the value of this new characteristic? ")
        melons[melon][characteristic] = additional_value   

    for melon, characteristics in melons.items():
        print melon.upper()
        for characteristic, value in characteristics.items():
            print "{}: {}".format(characteristic, value)    
        print  
def print_melon(melons):  # the dictionary name is passed as the parameter
    # so that interpreter knows where to pull attributes from
    """Print each melon with corresponding attribute information."""

    for name, attributes in melons.items(
    ):  # the name is the first feature or key whose features are being defined;
        #the attributes are the characteristics you define. Every key must have the same characteristics.
        print(name.upper())  # this prints the watermelon name in uppercase

        for attribute, value in attributes.items(
        ):  #items are the characteristics which have a value such as
            # None, a boolean, a string, a float or an int. Here the code says that for every attribute and value print
            # the attribute and value fields line by line
            print(f'{attribute}:{value}')
        print('-')
예제 #22
0
def print_melons(melons):
    """Print each melon followed by it's attributes

    Example:

    CANTALOUPE
      flesh_color: None
      price: 0.99
      rind_color: None
      seedless: False
      weight: None

    """

    for name, melon in sorted(melons.items()):
        print name.upper()
        for attribute, value in sorted(melon.items()):
            print "  {}: {}".format(attribute, value)
        print ""
예제 #23
0
def print_melon(melons):
    for melon_name, melon_info in melons.items():
        print melon_name.upper()
        for key, value in melon_info.items():
            print "  {} : {}".format(key, value)
def print_melon(melons):
    """Print each melon with corresponding attribute information."""
    for melon, details in melons.items():
        print(melon.upper())
        for detail, value in details.items():
            print(detail, value)
예제 #25
0
"""Print out all the melons in our inventory."""

from melons import melons

# print the nested dictionary, but with
# each key-value pair (item) on a separate line

for melon_name, melon_info in melons.items():

    print(melon_name.upper())
    for key, value in melon_info.items():
        print(f"    {key}: {value}")
    print()

### ---------------- OLD CODE --------------- ###
# from melons import melon_names, melon_seedlessness, melon_prices

# def print_melon(name, seedless, price):
#     """Print each melon with corresponding attribute information."""

#     have_or_have_not = 'have'
#     if seedless:
#         have_or_have_not = 'do not have'

#     print(f'{name}s {have_or_have_not} seeds and are ${price:.2f}')

# for i in melon_names:
#     print_melon(melon_names[i], melon_seedlessness[i], melon_prices[i])
예제 #26
0
def print_melon(melons):
    """Print each melon with corresponding attribute information."""
    for melon_type, attributes in melons.items():
        print('\n', melon_type.upper(), '\n')
        for melon_attr, val in attributes.items():
            print(f'{melon_attr}: {val}')
예제 #27
0
"""
Prints out all the melons in our inventory
"""

from melons import melons

for melon, items in melons.items():
    print melon.upper()
    for key, value in items.items():
        print "   {}: {}".format(key, value)