Class 6 If/elif/else Statement

Today we are going to learn about If/elif/else. Files are at https://github.com/bmaillou/BigDataPython/tree/master/06-ifelif

If you do this work:

you will know if statements

elif you partially do the work:

you might sort of know them

else:

you won’t get much out of today’s lecture!

Some reading

If statements
http://www.tutorialspoint.com/python/python_basic_operators.htm
http://www.tutorialspoint.com/python/python_decision_making.htm
http://www.tutorialspoint.com/python/python_if_else.htm
But we need to know Boolean
https://docs.python.org/2/library/stdtypes.html

Video

Don’t forget the quiz on courseworks.

Homework 5

Due Next Class Wednesday February 12, 2025

Regular Homework

  1. Go back and find when you plotted the parabola and sin x.  These are really nice graphs that you made.
    1. Use input and if statements to ask the user if they would like to plot sin x or to plot the parabola
    2. If they choose sin x use an input statement to determine the number of pi’s they want to plot and plot the appropriate graph.  This way you can show many pi values.
    3. If they choose a parabola have them enter the a,b,c of the parabola.
    4. For example if I choose sin of x I could then choose 32.1 pi’s to plot.
    5. For example if I choose parabola I could then choose a=1, b=-5, c=0.02
  2.  You should have all your code in one ipython box so I can just run that one box, do my entries, and then see the plots.  if-statements grading rubric
  3. Remember to use input()
  4. To get an integer or float (remember to use them correctly, You need to choose when you think an integer or float is more appropriate) use input like
    1. a=int(input(‘please enter a number as an integer’))
    2. myfloat=float(input(‘please enter a number as a float’))