Question: Lab: String Formatting In this lab you will write two short programs. Be sure to use comments and appropriate code style. Your program must execute

Lab: String Formatting
In this lab you will write two short programs. Be sure to use comments and appropriate code style. Your program must execute without runtime errors in order to receive any credit. Except for variables provided by the user as inputs, you must match the formatting from the example run exactly.
Program 1
In this program you will calculate the age difference between the user and Alan Turing, and print the result. Proceed with the following instructions:
Create a new file called program1.py
Declare a constant and store Alan Turing's birth year, 1912.
Prompt the user to enter their year of birth and store it in a variable.
Calculated the difference between the user's birth year and Turing's birth year. Store the result in a variable.
Print the difference between the user's birth year and Turing's birth year. The output should be formatted as shown in the example run. Use string concatenation to combine the strings and the variable (not f-strings).
Example Run:
Enter your year of birth: 1986 You are 74 years younger than Alan Turing.
Program 2
In this program you will get information for a library record and print it in tabular format. Proceed with the following instructions:
Create a new file called program2.py
Prompt the user to enter a first name and store it in a variable.
Prompt the user to enter a last name and store it in a variable.
Prompt the user to enter a title and store it in a variable.
Prompt the user to enter an ISBN and store it in a variable.
Print an empty line.
Print a header row for the table. The row should have three columns: Author, Title, and ISBN.
Author should be left aligned and take up 30 characters.Title should be left aligned and take up 30 characters.ISBN should be right aligned and take up 10 characters.
Print an underline row for the table using underscores. Each column should match the width and alignment of the header row.
Print the data row for the table using the data entered by the user. Each column should match the width and alignment of the header row. Author should be printed as last name, first name.
Example Run:
Author first name: Jonny Author last name: Writestuff Book title: Pigeons are the Best Animals ISBN: 1002307745 Author Title ISBN ______________________________________________________________________ Writestuff, Jonny Pigeons are the Best Animals 1002307745
About
sdev140_04_f24-string-formatting-140-string-formatting created by GitHub Classroom
Resources
Readme
Activity
Custom properties
Stars
0 stars
Watchers
0 watching
Forks
0 forks
Releases
No releases published
Create a new release
Packages
No packages published
Publish your first package
Footer
2024 GitHub,Inc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!