Python Syntax = Strings

Strings

When printing things in Python, we are supplying a text block that we want to be printed. Text di python is considered a specific type dari datacalled a string. A string, so named because they're a series of letters, numbers, or symbols connected in order — as if threaded together by string. Strings can be defined in different ways:
print "This is a good string" print 'You can use single quotes or double quotes for a string'
Above we printed two things that are strings and then attempted to print two things that are not strings. While double-quotes (") and single-quotes (') are both acceptable ways to define a string, a string needs to be opened and closed by the same type of quote mark.
Kita bisa menggabungkan beberapa string menggunakan +, like so:
print "This is " + "a good string"
This code will print out "This is a good string".
1.
Try adding your name to the printstatement with the + operator so that this Python program prints "Hello [your_name]"

Tidak ada komentar:

Posting Komentar