Question

python Programming. In this program you can use if, else and elif or list and dictionary....

python Programming.

In this program you can use if, else and elif or list and dictionary. If your loaf of bread has passed its expiration date and has become stale or is smooshed/damaged, or your bread smells sour or has colored spots on it, then throw it out.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution-1:-

loaf_of_bread_condition=eval(input("enter the bread condition"))

list1=["passed its expiration date","stale","smooshed","damaged","smells sour","has colored spots"]

if loaf_of_bread_condition in list1:

print("throw it out ")

Note:-

eval():-always takes string as input and produces output as the required datatype

in--->it is a membership operator [i.e it checks whether the given item present in list or not]

Add a comment
Know the answer?
Add Answer to:
python Programming. In this program you can use if, else and elif or list and dictionary....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python Develop a program that uses a list or dictionary that can be searched.   The...

    In Python Develop a program that uses a list or dictionary that can be searched.   The program should do some kind of processing of list or dictionary members.

  • Use python and use if, elif and else statements. Thank you! The program should first ask...

    Use python and use if, elif and else statements. Thank you! The program should first ask the user if they are a hero or a villain. If they enter “villain”, the program should ask them their name; if they enter “hero”, it should ask how many people they have saved, and respond to that information. Using decision structures, have your program execute certain print statements following these rules: If they enter that they are a villain Ask for their name...

  • Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/...

    Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/share/dict/words (if you machine does not have it, you can copy it from a Linux machine such as npu29). The minimum requirement is to check if each word in the file exists in the dictionary as is (case insensitive). Your spell checker should inlcude at least two features: 1. Check the simple plural forms (add s or es). 2. Check the simple verb past...

  • List of keywords in Python can be obtained with the statements import keyword kw = keyword.kwlist Use list comprehension...

    List of keywords in Python can be obtained with the statements import keyword kw = keyword.kwlist Use list comprehension to print out a lower case sorted 2-column list. The output should look as follows: and as assert async await break class continue def del elif else false except finally for from global if import in is lambda none nonlocal not or pass raise return try true while with yield and as assert async await break class continue def del elif...

  • Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file...

    Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original...

  • PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold...

    PYTHON PROGRAM by using functions & dictionary or set. - must create a variable to hold a dictionary or sets - must define a function that accepts dictionaries or sets as an argument A dictionary maps a set of objects (keys) to another set of objects (values). A Python dictionary is a mapping of unique keys to values. For e.g.: a dictionary defined as: released = { "iphone" : 2007, "iphone 3G": 2008, "iphone 3GS": 2009, "iphone 4" : 2010,...

  • In PYTHON ONLY PLEASE You will use a dictionary in Python You only have string in Python so you have to use a string dat...

    In PYTHON ONLY PLEASE You will use a dictionary in Python You only have string in Python so you have to use a string data type Use a Switch statement.A switch statement is just another way of writing an IF statement. The user will enter f, s, j, or r from the keyboard for freshman, sophomore, junior, or senior. Use character data type for c++. Then you can say something like: char level ='f'; level=toupper(level); You would need a loop...

  • Please help with this exercise on Python program involving the use of dictionary. ### This exercise...

    Please help with this exercise on Python program involving the use of dictionary. ### This exercise involves building a non-trivial dictionary. ### The subject is books. ### The key for each book is its title ### The value associated with that key is a dictionary ### ### In that dictionary there will be Three keys: They are all strings, they are: ### ### "Pages", "Author", "Publisher" ### ### ### "Pages" is associated with one value - an int ### ###...

  • Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write...

    Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write a program that will help an elementary school student to learn English. To simplify the model, the program will first teach numbers from 1 to 10, colors and fruits. It will use a dictionary to store the pairs Spanish-English words. dataTable-uno':one,'dos':'two....' rojo':'red','blue':'Azul... manzana': apple, nara nja:orange. When running your program, it should get a random Spanish word from the dictionary dataTable and then show...

  • python programming: Can you please add comments to describe in detail what the following code does:...

    python programming: Can you please add comments to describe in detail what the following code does: import os,sys,time sl = [] try:    f = open("shopping2.txt","r")    for line in f:        sl.append(line.strip())    f.close() except:    pass def mainScreen():    os.system('cls') # for linux 'clear'    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print(" SHOPPING LIST ")    print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")    print("\n\nYour list contains",len(sl),"items.\n")    print("Please choose from the following options:\n")    print("(a)dd to the list")    print("(d)elete from the list")    print("(v)iew the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT