Question: Python progamming question. Problem 2: Truth values Grading criterion: correctness and thoroughness. An expression e will be called truthy if bool (e) is True (.e.,

Python progamming question.

Python progamming question. Problem 2: Truth values Grading criterion: correctness and thoroughness.

Problem 2: Truth values Grading criterion: correctness and thoroughness. An expression e will be called truthy if bool (e) is True (.e., if if e: stuff executes stuff); otherwise e is falsy. 1a. Create a list 1 consisting of 10 different Python objects that are falsy. For correctness, your list must have the property that a is b evaluates to False whenever a and b are entries of the list in different positions. For thoroughness, the entries should look as different as possible. (Hint: is an example.) In [ ]: | |- [] #insert ten objects here In [ ]: # Use this code to test correctness of your answer! print(len (1)10) print(all (not 1[i for i in range (10))) print(al1 (not (liij is llj]) for i in range (10) for j in range(i+1,10))) 1b. In Python, "is" means "identical objects", whereas" can be much more subtle. Create a list 1 consisting of 5 tuples (a,b) for each of which a--b evaluates to True but a is b evaluates to False. In [ ]: I- [] #insert five objects here 1c. By analogy with the code snippet given in 1a, write a code snippet to verify correctness of your answer to 1b. That is, the code snippet should print one or more True/False values, all of which are True if and only if the answer is correct. In [ ]: # Your code snippet goes here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!