Thanhgiang
0
Q:

print variable string python

print "If there was a birth every 7 seconds, there would be: {} births".format(births)
1
foo = "seven"

print("She lives with " + foo + " small men")
5
variable = "Hello World"
print(variable)
1
name = "Bob"
print(f"hello {name}!")
1
var = "Python printing is amazing!"
print(var)
3
# This prints out "John is 23 years old."
name = "John"
age = 23
print("%s is %d years old." % (name, age))
# note: the letter is based on the datatype. %s = string, %d = decimal
0
print("If there was a birth every 7 seconds, there would be: {} births".format(births))
0
name = "Steven"

# Using f-strings
print(f"Hi, {name}!")

# Using format()
print("Hi, {}!".format(name))
0
>>> print("{:d} {:03d} {:>20f}".format(1, 2, 1.1))
1 002             1.100000
  ^^^
  0's padded to 2
0
str1 = "Hello World"
print(str1)
0

New to Communities?

Join the community