In python we can write "Hello World in one line":
print("Hello World!")
Another way we can do it is by declaring a variable holding the value ("Hello World"):
message = "Hello World"
print (message)
Values can also be concatenated by using the + sign. Let's create another variable with our name as the value:
message = "Hello World!"
myName = " My name is Programming Clue"
print(message + myName)
The output for this program will be:
Hello World! My name
Notice before "My name...." there is a blank space. This space was intentionally made to separate both values.
No comments:
Post a Comment