{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Name address value usrlocalbinpython3 converts

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: one statement per line 16 Comments Comments start with #, they can be anywhere in the line Comments are ignored by the compiler/Interpreter and exist for human eyes only #!/usr/local/bin/python3 # Converts temperatures from Fahrenheit to Celsius # Ask user for input F = float( input("Please enter a temperature in Fahrenheit: ") ) # Do the conversion C = (F-32)*5/9 # Print the result print("The temperature in Celsius is: ", C ) 17 Literals (= constants) String constant Literal = constant #!/usr/local/bin/python3 # Converts temperatures from Fahrenheit to Celsius # Ask user for input F = float( input("Please enter a temperature in Fahrenheit: ") ) # Do the conversion C = (F-32)*5/9 # Print the result print("The temperature in Celsius is: ", C ) Numeric constant 18 6 13 ­09 ­10 Variables Variables allow one to refer to values using easy-to-remember names. name address value #!/usr/local/bin/python3 # Converts temperatures from Fahrenheit to Celsius # Ask user for input F = float( input("Please enter a temperature in Fahrenheit: ") ) # Do the conversion C = (F-32)*5/9 # Print the result print("The temperature in Celsius is: ", C ) 19 Memory Addresses 001 12 004 1304 002 27 005 54 003 8 006 99 How much can we store? In each drawer we can store a word Word length?: •  32 bit CPUs 32 bit words •  64 bit CPUs 64 bit words •  8 bits = 1 byte •  32 bits = 4 bytes •  64 bits = 8 bytes Contents 20 Variables are beVer than memory addresses • What is the problem with using memory addresses?   Hard to remember   We can confuse different memory loca3ons   We have to decide about the loca3on • Variables address these issues   Variable = Name + Address   The compiler/interpreter assigns the addresses •  We don’t have to worry about this!   Programmer’s perspec3ve: •  Create variable by introducing a name •  Use the variable   A variable represents what is stored at the address 21 7 13 ­09 ­10 Variables Name Address A 003 Age 005 Height 12 004 1304 27 005 5...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern