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
-
Go back and find when you plotted the parabola and sin x. These are really nice graphs that you made.
-
Use input and if statements to ask the user if they would like to plot sin x or to plot the parabola
- 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.
- If they choose a parabola have them enter the a,b,c of the parabola.
- For example if I choose sin of x I could then choose 32.1 pi’s to plot.
- For example if I choose parabola I could then choose a=1, b=-5, c=0.02
-
-
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
-
Remember to use input()
-
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
-
a=int(input(‘please enter a number as an integer’))
-
myfloat=float(input(‘please enter a number as a float’))
-