Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section 3.2 discusses the fact that you can nest control structures in Python a. (10 pts) What does it mean to nest control structures in

image text in transcribed

Section 3.2 discusses the fact that you can nest control structures in Python a. (10 pts) What does it mean to nest control structures in Python? (Note: you won't find the answer spelled out in the text. It is implied, but not clearly explained. So you'll have to do some thinking to figure out how to answer. That's on purpose.) b. (10 pts) What can you see in the Python code (or do you have to write in your own Python code) to indicate that something is "nested" (This is also in the text, but implied rather than stated.) Section 3.2 discusses iteration, which means doing things over and over again, in a loop. As we will learn, there is more than one kind of loop in Python, but there is a particular kind of loop discussed in Section 3.2 that allows us to process each character in a string, or each item in a list, one at a time What is the Python word that starts that kind of loop? the textbook suggests using the eval) function to convert the result of input) from the user if it going to be used as something other than a string (e.g. as a number, list, etc.) THIS IS A POTENTIALLY DANGEROUS HABIT TO GET INTO. DON'T DO IT. (We'll discuss this in more detail in lecture, but the short version is: this is the kind of habit that leaves security vulnerabilities open for hackers. There isn't any real danger in an intro course, because the software you write won't be run by anyone except you and your TA, but in general, this is VERY bad habit to get into.) So what can we do instead? Well, you actually already saw one option-a technique that was discussed in Section 2.4. Suppose we have this Python statement: ageAsString input( Please enter your age in years Using techniques from Section 2.4, but NOT using eval, what line of Python code can you write to convert the value ageAsString into an int value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions