# Pavan Kumpatla
# Dec 13, 2021
# I learned how to format with the old and new styles
# I had difficulties with the last part of task 1 and 2
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %d was $ %f' % (year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %i was $ %3.2f' % (year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %i was $ %08.2F' % (year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %d was $ %e' % (year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %d was $ %3.2e' % (year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in %d was $ %3.2E' % (year, price))
# prints, formats
first_name = input("Enter your first name: ")
# stores user input
last_name = input("Enter your last name: ")
# stores user input
print('The first name starts with: %c' % (first_name[0]))
# prints, formats
print('The last name ends with the 2 chars: %s' %(last_name[-2:]))
# prints, formats
from math import pi
# from math, import pi
print("Right adjusted: %20.2f" %(pi))
# prints, formats
print("Left adjusted: %-20.2f" %(pi))
# prints, formats
# [ ] Use the variables `F` and `C` to generate the following print outputs
'''
75 Fahrenheit = 23.888900 Celsius
75 Fahrenheit = 23.89 Celsius
75 Fahrenheit = 000023.889 Celsius
75 Fahrenheit = 23.889 Celsius
75 Fahrenheit = 23.889 Celsius
75 Fahrenheit = 2.389E+01 Celsius
75 Fahrenheit = 2.389e+01 Celsius
'''
F = 75
# stores
C = 23.8889
# stores
print("%d Fahrenheit = %f Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %4.2f Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %010.3f Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %-10.3f Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %10.3f Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %1.3E Celsius" % (F, C))
# prints, formats
print("%d Fahrenheit = %1.3e Celsius" % (F, C))
# prints, formats
# [ ] Use the string variables below to generate the following print outputs
# HINT: Set the name formatter width to 10 characters
first_name = 'Tamara'
# stores
last_name = 'Babic'
# stores
'''
Name: Tamara Babic
Name: Tamara Babic
Name: Tamara Babic
Name: Tamara Babic
Name: Tamara Babic
Name: Tamara Babic
'''
print("Name: %s %s" % (first_name, last_name))
# prints, formats
print("Name: %10s %10s" % (first_name, last_name))
# prints, formats
print("Name: %s %14s" % (first_name, last_name))
# prints, formats
print("Name: %10s %s" % (first_name, last_name))
# prints, formats
print("Name: %s %9s" % (first_name, last_name))
# prints, formats
print("Name: %s %s" % (first_name, last_name))
# prints, formats
# [ ] The list `data` contains personnel information (Name, ID, email)
# Write a program to print out the data as follows:
'''
Name ID Email
--------------------------------------------------
Suresh Datta 57394 suresh@example.com
Colette Browning 48539 colette@example.com
Skye Homsi 58302 skye@example.com
Hiroto Yamaguchi 48502 hiroto@example.com
Tobias Ledford 48291 tobias@example.com
Jin Xu 48293 jin@example.com
Joana Dias 23945 joana@example.com
Alton Derosa 85823 alton@example.com
'''
data = [["Suresh Datta", 57394, "suresh@example.com"], ["Colette Browning", 48539, "colette@example.com"], ["Skye Homsi", 58302, "skye@example.com"], ["Hiroto Yamaguchi", 48502, "hiroto@example.com"], ["Tobias Ledford", 48291, "tobias@example.com"], ["Tamara Babic", 58201, "tamara@example.com"], ["Jin Xu", 48293, "jin@example.com"], ["Joana Dias", 23945, "joana@example.com"], ["Alton Derosa", 85823, "alton@example.com"]]
# stores data
print("Name ID Email")
# prints
print("--------------------------------------------------")
# prints
print(data[0])
# prints index 0
print(data[1])
# prints index 1
print(data[2])
# prints index 2
print(data[3])
# prints index 3
print(data[4])
# prints index 4
print(data[5])
# prints index 5
print(data[6])
# prints index 6
print(data[7])
# prints index 7
# NOTE:- I really don't know how to do this one.
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in {:d} was $ {:f}'.format(year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in {0:d} was $ {1:3.2F}'.format(year, price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in {y:d} was $ {p:1.2e}'.format(y = year, p = price))
# prints, formats
year = 2017
# stores
price = 2.42011
# stores
print('The national average gas price in {:d} was $ {:010.2f}'.format(year, price))
# prints, formats
first_name = input("Enter your first name: ")
# stores user input
last_name = input("Enter your last name: ")
# stores user input
print('The first name starts with: {:s}'.format(first_name[0]))
# prints, formats
print('The last name ends with the 2 chars: {:s}'.format(last_name[-2:]))
# prints, formats
# No longer needs "c", we can just use "s"
from math import pi
# from math, import pi
print('Right adjusted : {:<20.2f}'.format(pi))
# prints, formats
print('Center adjusted: {:^20.2f}'.format(pi))
# prints, formats
print('Left adjusted : {:>20.2f}'.format(pi))
# prints, formats
from math import pi
# from math, import pi
# Padding with zeros
print('Right adjusted : {:0<20.2f}'.format(pi))
# prints, formats
print('Center adjusted: {:0^20.2f}'.format(pi))
# prints, formats
print('Left adjusted : {:0>20.2f}'.format(pi))
# prints, formats
from math import pi
# from math, import pi
# Padding with underscore characters
print('Right adjusted : {:_<20.2f}'.format(pi))
# prints, formats
print('Center adjusted: {:_^20.2f}'.format(pi))
# prints, formats
print('Left adjusted : {:_>20.2f}'.format(pi))
# prints, formats
# [ ] Use Python-style formatting and the variables `F` and `C` to generate the following print outputs
'''
75 Fahrenheit = 23.888900 Celsius
75 Fahrenheit = 23.89 Celsius
75 Fahrenheit = 0000023.89 Celsius
75 Fahrenheit = 23.889 Celsius
75 Fahrenheit = 23.889 Celsius
75 Fahrenheit = 23.889 Celsius
75 Fahrenheit = 2.389E+01 Celsius
'''
F = 75
# stores value
C = 23.8889
# stores value
print("{:d} Fahrenheit = {:f} Celsius". format(F, C))
# prints, formats
print("{:d} Fahrenheit = {:1.2f} Celsius". format(F, C))
# prints, formats
print("{:d} Fahrenheit = {:010.2f} Celsius". format(F, C))
# prints, formats
print("{:d} Fahrenheit = {:<10.3f} Celsius". format(F, C))
# prints, formats
print("{:d} Fahrenheit = {:<10.3f} Celsius". format(F, C))
# prints, formats - I can't get this one
print("{:d} Fahrenheit = {:10.3f} Celsius". format(F, C))
# prints, formats
print("{:d} Fahrenheit = {:1.3E} Celsius". format(F, C))
# prints, formats
# [ ] Use Python-style formatting and the string variables below to generate the following print outputs
# HINT: Set the name formatter width to 10 characters
first_name = 'Tamara'
# stores
last_name = 'Babic'
# stores
'''
Name: Tamara Babic
Name: Tamara Babic
Name: Tamara____ _____Babic
Name: __Tamara__ __Babic___
Name: ____Tamara Babic_____
Name: Tamara Babic
'''
# print("Name: {:s} {:s}".format(first_name, last_name))
print("Name: {:s} {:s}".format(first_name, last_name))
# prints, formats
print("Name: {:15s} {:15s}".format(first_name, last_name))
# prints, formats
print("Name: {:_<10s} {:_>10s}".format(first_name, last_name))
# prints, formats
print("Name: {:_<8s} {:_>7s}".format(first_name, last_name))
# prints, formats -
# NOTE:- I don't know how to do this one ^ (the before one)
print("Name: {:_>10s} {:_<10s}".format(first_name, last_name))
# prints, formats
print("Name: {:>10s} {:<10s}".format(first_name, last_name))
# prints, formats
# [ ] The list `data` contains personnel information (Name, ID, email)
# Write a program using Python-style formatting to print out the data as follows:
'''
Name | ID | Email
________________________________________________________
Suresh Datta | 57394 | suresh@example.com
Colette Browning | 48539 | colette@example.com
Skye Homsi | 58302 | skye@example.com
Hiroto Yamaguchi | 48502 | hiroto@example.com
Tobias Ledford | 48291 | tobias@example.com
Jin Xu | 48293 | jin@example.com
Joana Dias | 23945 | joana@example.com
Alton Derosa | 85823 | alton@example.com
'''
data = [["Suresh Datta", 57394, "suresh@example.com"], ["Colette Browning", 48539, "colette@example.com"], ["Skye Homsi", 58302, "skye@example.com"], ["Hiroto Yamaguchi", 48502, "hiroto@example.com"], ["Tobias Ledford", 48291, "tobias@example.com"], ["Tamara Babic", 58201, "tamara@example.com"], ["Jin Xu", 48293, "jin@example.com"], ["Joana Dias", 23945, "joana@example.com"], ["Alton Derosa", 85823, "alton@example.com"]]
# stores data
print(" Name | ID | Email")
# prints
print("________________________________________________________")
# prints
print("{}".format(data[0]))
# prints index 0
print("{}".format(data[1]))
# prints index 1
print("{}".format(data[2]))
# prints index 2
print("{}".format(data[3]))
# prints index 3
print("{}".format(data[4]))
# prints index 4
print("{}".format(data[5]))
# prints index 5
print("{}".format(data[6]))
# prints index 6
print("{}".format(data[7]))
# prints index 7
print("{}".format(data[8]))
# prints index 8