Forum Archive

Help with 2 Python questions

Pythonistapro777

I am doing an online quiz, (teacher recommended) and I need help with these 2 questions. I have selected what i think is the answer but could someone please tell me if I'm right or wrong?
I don't want to have to do the quiz a 5th time around. :(
Question 1. Which of these is not one of the four types of control flow used in programs:
1. Repeated
2. Sequential
3. Fused/Multi-Path
4. Store and Reuse

I chose: Fused / Multi-Path

Question 2. In the following example, an error occurs in "line3" that normally causes a traceback. What is the sequence of lines executed in this program:
line1
try:
line2
line3
line4
except:
line5
line6

  1. line1 line2 line3 line5 line6
  2. line1 line6
  3. line1 line2 line3 line4 line2 line6
  4. line1 line2 line3 line4 line5 line6

I chose: line1 line2 line3 line5 line6

Webmaster4o

Your answer to question 2 is wrong. This is also not an appropriate question for this forum (in my opinion) as it has nothing to do with pythonista, it's just generally about Python. Please post it on stackoverflow.

Pythonistapro777

OK. Is question 1 correct, though. @Webmaster4o

Webmaster4o

I think so.

dgelessus

Not to be rude, but asking us to do the quiz for you doesn't help you in any way. If we tell you the answers, you'll complete the quiz, but you haven't learned anything. The next time you get a similar question in an exam, you won't be able to answer it correctly (especially if your exam is not a multiple-choice test and you have to write a full answer yourself).

If you're not sure that your answers are correct, look through your school book or worksheets that you were given in class. If you were right, then great! If not, then compare the correct answer with the one you thought was right and see what you understood wrong. The next time you'll know better. If you're still unsure and have more questions, ask your classmates or your teacher. They can answer your questions better than we can, because they know what you've already learned in class. Not to mention that it's a lot quicker to ask someone in real life than to wait hours for random internet people. ;)

Pythonistapro777

Yes, i understand. Thats why i didnt ask for the answers - i only asked if i was wrong.

ccc

Question 2 is easy to figure out:
* Change all occurrences of 'line' to 'print' (with a trailing space before the number).
* Add '; throw(Error)' to the end of line 3.
* Make sure your indentation exactly matches the quiz question.
* Run the program for you answer.

dgelessus

@ccc said:

  • Add '; throw(Error)' to the end of line 3.

Normally you'd write raise Exception(). Of course throw(Error) works as well - it'll give you a NameError, because the name throw is not defined. ;)

ccc

LOL... Good catch. You are correct.

Phuket2

@Pythonistapro777 , are you on stackflow? It's a great site. Covers a lot of languages, I guess probably all. Absolute massive database of answers to all sorts of questions. I ask some Python oriented questions here sometimes because I am not exactly sure if there are some limitations or differences about running in Pythonista.
But look if you are not on stackflow, get on there ASAP. You will love it. So many things have already been answered. I use use it all the time. As far as I know, it's the by far the biggest programming resouce on the web. No sign up fees, you can sign in with your Facebook account if you wish.
Again, don't sweat it too much. It's just using the right resources for the right answers. You also have to be disciplined on stackflow. They want you to search for your answer first, rather than just post a question. Its understandable, otherwise you end up with literally thousands of duplicated questions.
Btw, I would have got question 2 wrong also :) but I would have done what was suggested by putting in the print statements.
Happy coding!