SJSU/Udacity CS046

Lesson 4 - Fundamental Data Types

  1. Introduction
  2. Introducing Ingrid
  3. Working with Numbers
  4. Quiz: Overflow
  5. Quiz: Precision
  6. Doubles Are Fuzzy
  7. Quiz: Number Types
  8. Quiz: Arithmetic Operations
  9. Quiz: Integer Arithmetic
  10. Quiz: Arithmetic Operations 2
  11. Ingrid Talks About Order of Operations
  12. Quiz: Color Reduction
  13. Quiz: Color Reduction 2
  14. Quiz: Day of the Week
  15. Quiz: Checkerboard
  16. Quiz: Casts
  17. How to Cast
  18. Quiz: Casts 2
  19. Ingrid Talks about Learning Casting
  20. Quiz: Grayscale
  21. Quiz: Math Functions
  22. Quiz: Sunset Effect
  23. Quiz: Magic Number
  24. Reading Input
  25. Quiz: Your Own Sunset Effect
  26. Formatted Output
  27. Quiz: Practice Formatted Output
  28. Quiz: Formatted Output Practice Part 2
  29. First Do It by Hand
  30. First Do It by Hand Part 2
  31. Quiz: Your Turn to Do It by Hand
  32. Quiz: Strings
  33. Working with Text
  34. Quiz: Working with the Book Text
  35. Quiz: Mad Hatter
  36. Quiz: Get the First Sentence
  37. Quiz: Get the Second Sentence
  38. Quiz: Occurrence of Alice
  39. Quiz: Occurrence of Any Word
  40. Quiz: Putting It All Together
  41. Quiz: Polish Our Code
  42. Calculating Circular Fields
  43. Formula for Calculating Circular Fields
  44. Quiz: How Many Rows of Fields
  45. Quiz: How Many Columns Can We Fit?
  46. Quiz: Number of Odd vs. Even Rows
  47. Quiz: How Many Fields Can We Fit?
  48. Quiz: Let's Program It Up
  49. How Programming Impacted Ingrid's Life
  50. Advice from Ingrid

Quiz: Number Types

Rearrange the following lines of code to produce variable declarations for

  1. the number of visitors to a small doctor's office today
  2. the number of gallons of water used per day
  3. the number of page views of a website viewed by users this quarter
  4. how long it takes a radioactive oxygen isotope to decrease by half

Initialize each variable with one of

  • 123
  • 123E2
  • 123L
  • 123.
Type of visitorCount int The doctor won't have a billion visitors, nor fractional visitors.
Initial value of visitorCount 123
Type of gallons double You can have fractional gallons.
Initial value of gallons 123. 123E2 or 123 would have worked too.
Type of pageViews long Youtube has billions of page views.
Initial value of pageViews 123L 123 would have worked too.
Type of halfLife double As it happens, 15O has a half life of close to 123 seconds.
Initial value of halfLife 123. 123 would have worked too.

Where the slide says "radioactively tagged oxygen", It should say "radioactive oxygen isotope"

Note: Udacity was opposed to requiring a book with the course and put a few facts onto a “fact sheet”. It didn't work well. Get a book!

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =