Interpolação de string com % em Python
This commit is contained in:
12
aula25.py
Normal file
12
aula25.py
Normal file
@@ -0,0 +1,12 @@
|
||||
"""
|
||||
Interpolação básica de strings
|
||||
s - string
|
||||
d e i - int
|
||||
f - float
|
||||
x e X - Hexadecimal (ABCDEF0123456789)
|
||||
"""
|
||||
nome = 'Luiz'
|
||||
preco = 1000.95897643
|
||||
variavel = '%s, o preço é R$%.2f' % (nome, preco)
|
||||
print(variavel)
|
||||
print('O hexadecimal de %d é %08X' % (1500, 1500))
|
||||
Reference in New Issue
Block a user