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
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 programpy
Declare a constant and store Alan Turing's birth year,
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 fstrings
Example Run:
Enter your year of birth: You are years younger than Alan Turing.
Program
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 programpy
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 characters.Title should be left aligned and take up characters.ISBN should be right aligned and take up 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: Author Title ISBN Writestuff, Jonny Pigeons are the Best Animals
About
sdevfstringformattingstringformatting created by GitHub Classroom
Resources
Readme
Activity
Custom properties
Stars
stars
Watchers
watching
Forks
forks
Releases
No releases published
Create a new release
Packages
No packages published
Publish your first package
Footer
GitHub,Inc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
