formatting strings in python
age = 11
my_self = "My name is Vishnu, I am " + str(age)
print(my_self)
formatting strings in python
age = 11
my_self = "My name is Vishnu, I am " + str(age)
print(my_self)
print python format
print('{} {}'.format(1, 2))
print formatted string in python
print("Geeks : %2d, Portal : %5.2f" % (1, 05.333))
# print integer value
print("Total students : %3d, Boys : %2d" % (240, 120))
# print octal value
print("%7.3o" % (25))
# print exponential value
print("%10.3E" % (356.08977))
python format string
>>> 'Coordinates: {latitude}, {longitude}'.format(latitude='37.24N', longitude='-115.81W')
'Coordinates: 37.24N, -115.81W'
>>> coord = {'latitude': '37.24N', 'longitude': '-115.81W'}
>>> 'Coordinates: {latitude}, {longitude}'.format(**coord)
'Coordinates: 37.24N, -115.81W'
string formatting python
>>> 'Hello, %s' % name
"Hello, Bob"
formatted string in python
>>> name = "world"
>>> print(f"Hello {name}!)"
'Hello world!'
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us