PYTHON β PRINT EXERCISES
How do you print the string βHello, world!β to the screen?
print("Hello World")
How do you print the value of a variable name which is set to βSyed Jaferβ or Your name?
name ="Jagadish"
print(name)
How do you print the variables name, age, and city with labels βName:β, βAge:β, and βCity:β?
name = "Tom"
age=25
city = "Chennai"
print("My name is {}, and my age is {}, Currently leaveing in City is {}".format(name, age, city))
How do you use an f-string to print name, age, and city in the format βName: β¦, Age: β¦, City: β¦β?
name = "Tom"
age=25
city = "Chennai"
print(f"Name : {name}, Age :{age},City : {city}")
How do you concatenate and print the strings greeting (βHelloβ) and target (βworldβ) with a space between them?
greeting = "Hello"
target = "world"
print(greeting,target)
How do you print three lines of text with the strings βLine1β, βLine2β, and βLine3β on separate lines?
print("""Welcome"
To python free class
from Kaniyam""")
How do you print the string He said, "Hello, world!" including the double quotes?
print(' He said, "Hello, world!"')
How do you print the string C:\Users\Name without escaping the backslashes?
print(r"C:\Users\jagadishwarang\Downloads")
How do you print the result of the expression 5 + 3?
a = 5
b = 3
print(a+b)
How do you print the strings βHelloβ and βworldβ separated by a hyphen -
print("Hello", "world", sep="-")
How do you print the string βHelloβ followed by a space, and then print βworld!β on the same line?
print("Hello world")
How do you print the string βHello β three times in a row?
print("Hello" * 3)