Question
2.17 Write Boolean expressions corresponding to the following logical statements and evaluate the expressions: (a) The sum of 17 and -9 is less than 10.
2.17 Write Boolean expressions corresponding to the following logical statements and evaluate the expressions: (a) The sum of 17 and -9 is less than 10. (b) The length of list inventory is more than five times the length of string fullname. (c) c is no more than 24. (d) 6.75 is between the values of integers a and b. (e) The length of string middle is larger than the length of string first and smaller than the length string last. (f) Either the list inventory is empty or it has more than 10 objects in it. 2.18 Write Python statements corresponding to the following: (a) Assign to variable flowers a list containing strings 'rose', 'bougainvillea', 'yucca', 'marigold', 'daylilly', and 'lilly of the valley'. (b) Write a Boolean expression that evaluates to True if string 'potato' is in list flowers, and evaluate the expression. (c) Assign to list thorny the sublist of list flowers consisting of the first three objects in the list. (d) Assign to list poisonous the sublist of list flowers consisting of just the last object of list flowers. (e) Assign to list dangerous the concatenation of lists thorny and poisonous. 2.19 A dartboard of radius 10 and the wall it is hanging on are represented using the twodimensional coordinate system, with the boards center at coordinate (0,0). Variables x and y store the x- and y-coordinate of a dart hit. Write an expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and evaluate the expression for these dart coordinates: (a) (0,0) (b) (10,10) (c) (6, 6) (d) ( 7,8)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started