Follow some examples of how to print information friendly in tab layout:
last, first = input("Enter your last and first names: ").split() stdID = input("Enter your ID: ") program = input("Enter your program name: ") print("") print("%-20s" % "Programmer name:", first, last) print("%-20s" % "Programmer ID:", stdID) print("%-20s" % "Program:", program) print("") print("Name:", first.lower(), last.upper()) print("") f11, f12 = input("Enter the first fruit name and its price: ").split() f12 = "$" + f12 f21, f22 = input("Enter the second fruit name and its price: ").split() f22 = "$" + f22 f31, f32 = input("Enter the third fruit name and its price: ").split() f32 = "$" + f32 print("") print("%-20s %-20s" % ("Fruit","Price/Kg")) print(f11.ljust(20, " "), f12.ljust(20, " ")) print(f21.ljust(20, " "), f22.ljust(20, " ")) print(f31.ljust(20, " "), f32.ljust(20, " "))
Copy, paste, and run this code. See below the output of this program:
Another example of how to input data, manipulate data, compute data, and print data:
fisrt_name, last_name = input("Enter your first and last names: ").split() user_id = input("Enter your ID: ") program_name = input("Enter the program name: ") radius = float(input("\nEnter the radius of the circle: ")) pi = float(3.14159) print("\n%-20s" % "Programmer name: " , fisrt_name , last_name) print("%-20s" % "ID: " , "%-10s" % user_id) print("%-20s" % "Program: " , "%-10s" % program_name) print("\nA circle of radius" , radius , "has:") print("%-20s" % "1. Circumference: " , "%-10.2f" % (2radiuspi)) print("%-20s" % "2. Area: " , "%-10.2f" % (radiuspi*2)) print("\nThe memory location used by r =" , radius , "is:" , id(radius))
Copy, paste, and run this code to get the same output as shown below: