1. Engineering
  2. Computer Science
  3. section 32 discusses the fact that you can nest control...

Question: section 32 discusses the fact that you can nest control...

Question details

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 wont find the answer spelled out in the text. It is implied, but not clearly explained. So youll have to do some thinking to figure out how to answer. Thats 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. DONT DO IT. (Well 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 isnt any real danger in an intro course, because the software you write wont 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?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution