Use the command line to create a new directory called lab2 in your labs directory. Make sure all of the .py files that you create for this activity are in that directory.
Now that you know expressions, you can use them to compute values that are very difficult to compute in your head. For example, what if an
shows up on Earth, and demands to know how old you are? Being aliens they have no concept of years, only seconds. While computing that by hand might be a chore, Python can rescue us from certain doom.Details
In Emacs, create a Python program in a file called age_in_seconds.py in your lab2 directory. The program should print your age in seconds. Assume there are 365 days in a year. You don't need to compute your exact age, just convert your age in years to seconds. The program should use Python's arithmetic operations to perform the calculations and should print the number of seconds nicely formatted an labeled.
Example
$ python3 age_in_seconds.py Scotty's age in seconds is 8830080000
Hint
Challenge
Of course, those aliens probably use some other time as opposed to just using our seconds. Let's assume for a second that one of their seconds is 5.4 of ours. How would your expression change if this was the case?
It's that time of the class where we ask you to get to know your fellow classmates. Of course, the sole purpose of this activity is not just getting to know one another. It's also a fantastic example of how to use the print statement, and how you can use the results of an expression in a print statement.
Details
In Emacs, create a python program in a file called classmates.py. The program should print a table like the one shown below. However, instead of Sally, Alexander, Graham, and Terry, you should put your and your lab partner's information and information about two classmates sitting near you. The program should not use spaces to align columns. Instead use the tab character, "\t".
The program should also print the average age of the four people. The output should be nicely formatted in a sentence that is all one line. The program should compute the average age using the Python arithmetic operators. When you test your program, be sure to verify that the calculation is correct!
Example
$ python3 classmates.py Name Hometown Intended Major Age ==== ======== ============== === Sally Roanoke Computer Science 18 Alexander Washington Math 19 Graham Charlottesville Physics 19 Terry Richmond Undecided 18 The average age is 18.5.
Hint
Challenge
You are only required to have 4 rows in your table. However, it would be very advantageous for you to get to know more people from the class. Time permitting, go talk to as many people in the class as possible, and add them to the table as well.
Submission
Please show your source code and run your programs for the instructor or lab assistant. Only a programs that have perfect style and flawless functionality will be accepted as complete.