PYTHON 6 MR HUSCH OBJECTIVE Practice more lines
PYTHON 6 MR. HUSCH
OBJECTIVE • Practice more lines of code • KEEP DOING YOUR ERROR LOG
WHAT DOES THE % SIGN DO IN THE CODE WE ARE ABOUT TO LOOK AT? • %r is not on that chart, why not? %r is an unambiguous string, something that may need to change formats as it is reading. Traditionally you would use %s for a string, but if %s is not defined it will allow you to use %r in place of it. • I do not know why this lesson wants us to use %r instead of %s, both should work the same with one difference in the final run code. Format Symbol Conversion %c character %s string conversion via str() prior to formatting %i signed decimal integer %d signed decimal integer %u unsigned decimal integer %o octal integer %x hexadecimal integer (lowercase letters) %X hexadecimal integer (UPPERcase letters) %e exponential notation (with lowercase 'e') %E exponential notation (with UPPERcase 'E') %f floating point real number %g the shorter of %f and %e %G the shorter of %f and %E
ENTER THE FOLLOWING CODE: SAVE AS LASTNAME_PYTHON 6
QUESTIONS: ANSWER IN YOUR JOURNAL FOR QUESTION 3 YOU WILL NEED TO EDIT THE CODE. • 1) What changes from the code to the display in the one, two, three, four sequence? • 2) What are parentheses used for in this code? • 3) What changes to the code if you switch %r to %s? • Log any errors and do not repeat them next time
WE NOW HAVE A LITTLE BASELINE, FOR THE REST OF CLASS WORK ON THE FOLLOWING WEBSITE. • https: //www. codecademy. com/learn/python
- Slides: 6