python 查找 一组
Program 1:
程序1:
print "Hello",
print "World"
Output
输出量
Hello World
Explanation:
说明:
There is a comma after the statement print "Hello", it prevents to print the new line after printing the message and inserts a space after the message.
语句print “ Hello”后有一个逗号,它防止在打印消息后打印新行,并在消息后插入空格。
Thus, first statement will print "Hello " ("Hello" and a space) and second statement will print "World" and then new line.
因此,第一个语句将打印“ Hello” ( “ Hello”和一个空格 ),第二个语句将打印“ World” ,然后打印新行。
Thus, the output will be "Hello World" and after that, if we print any message - that will be printed in separate line.
因此,输出将为“ Hello World” ,此后,如果我们打印任何消息,则将在单独的行中打印。
Program 2:
程式2:
print "Hello", "World"
Output
输出量
Hello World
Explanation:
说明:
There is a comma after the statement print "Hello", it prevents to print the new line after printing the message and inserts a space after the message.
语句print “ Hello”后有一个逗号,它防止在打印消息后打印新行,并在消息后插入空格。
Thus, first statement will print "Hello " ("Hello" and a space) and second statement will print "World" and then new line.
因此,第一个语句将打印“ Hello” ( “ Hello”和一个空格 ),第二个语句将打印“ World” ,然后打印新行。
Thus, the output will be "Hello World" and after that, if we print any message - that will be printed in separate line.
因此,输出将为“ Hello World” ,此后,如果我们打印任何消息,则将在单独的行中打印。
Program 3:
程式3:
print 'Hello World'
print "Hello World"
print '''Hello World'''
print """Hello World"""
Output
输出量
Hello World
Hello World
Hello World
Hello World
Explanation:
说明:
Print with single quotes, double quotes, triple single quotes and triple double quotes prints the text. Thus, the output is same.
用单引号,双引号,三重单引号和三重双引号打印可打印文本。 因此,输出是相同的。
One difference is there, normal single quotes and normal double quotes prints single line text, while triple single quotes and triple double quotes are able to print multiple line text.
有一个区别,普通单引号和普通双引号可以打印单行文本,而三重单引号和三重双引号可以打印多行文本。
Program 4:
计划4:
print '''Hello
World'''
print """Hello
World"""
print """Hello
World"""
Output
输出量
Hello
World
Hello
World
Hello
World
Explanation:
说明:
As we mentioned in the explanation of question3 that triple single quotes and triple double quotes print the text as it is written i.e. in multiple lines also.
正如我们在对问题3的解释中提到的那样,三重单引号和三重双引号会在编写文本时即打印多行时打印文本。
python 查找 一组