Added lecture 2026113
This commit is contained in:
parent
be356ccb59
commit
5b630435ae
27 changed files with 738 additions and 0 deletions
29
lecture20261103/lists02/fstringprimer.py
Normal file
29
lecture20261103/lists02/fstringprimer.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import math
|
||||
|
||||
#Integers
|
||||
someInteger = 3
|
||||
someInteger2 = 456
|
||||
|
||||
#Floats
|
||||
someFloat = 7.
|
||||
someFloat2 = 78.9
|
||||
dollarAmount = 696.05
|
||||
piFloat = math.pi
|
||||
|
||||
#Basic Print
|
||||
print("Basic Print")
|
||||
print(someInteger, someFloat2)
|
||||
print(someInteger2, piFloat)
|
||||
|
||||
# formatted Print without print spec
|
||||
print("Formatted Print without print spec")
|
||||
print(f"{someInteger} {someFloat2}")
|
||||
print(f"{someInteger2} {piFloat}")
|
||||
|
||||
# formatted Print with print spec
|
||||
# Note - 8.6f means format a float with a minimum
|
||||
# of 8 spaces wide and 6 places to the right of the decimal point.
|
||||
print("Formatted Print with print spec")
|
||||
print(f"{someInteger:5d} {someFloat2:6.2f}")
|
||||
print(f"{someInteger2:5d} {piFloat:8.6f}")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue