Intro to Python: Numbers and Strings

Useful references:


Answer the following questions:

Question One:

What is a literal in python? How is it different from a variable?




Question Two:

In the following code typed into the python interpreter, what will python print? Explain.



Question Three:

What is operator overloading? Give an example.





Question Four:

What happens when you attempt to add a float and an int? What is this called? (See: Zelle, Chapter 3.6)




Question Five:

Provide two expressions that could create s, such that the command shown below generates the given output:





Question Six:

How do you access the second through the fifth characters in a string named s? Assume that s contains more than ten characters.

Question Seven:

Explain what a string object's "find" method does. Hint: create a string object in the interpreter, and then ask for help.




Question Eight:

What do you type into the interpreter to indicate a tab character? (Hint: review your answer for Question Five.)




Question Nine:

Demonstrate a sequence of python commands that demonstrate how you would calculate the largest python int.




Question Ten:

How does python handle a situation where an operation on an int generates a result that is larger than the largest int, where the result is an integer?




finis!