python means

Python Strings,Text and Printing

Despite having experience developing Python strings, you are still unsure of their function. To help you understand what these variables are for, we’ve created a ton of them with intricate strings for this exercise. Python strings are first described.

What is Python Strings?

A python strings is typically some text that you want to “export” from the program you are building or display to someone. Python understands that you want something to be a string when you surround it with either ” (double-quotes) or'(single-quotes). When you use print and place the text you want to go to the string inside of ” or’after the print, you have probably seen this a lot. Python then outputs it.

The format characters you have discovered so far may be found in python strings. The formatted variables are simply added to the string, followed by the percent sign (%) and the variable. The only exception is that you must place your formats inside of () parentheses and separate them with commas if you want your string to output multiple variables using different formats. It’s like you told me what you wanted from the supermarket and said, “I want milk, eggs, bread, and soup.” Only in programming do we say, “(milk, eggs, bread, soup).”


We will now type in a whole bunch of strings, variables, and formats, and print them. You will also practice using short abbreviated variable names. Python Programmers love saving themselves time at your expense by using annoying cryptic variable names, so let’s get you started being able to read and write them early on.

x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)

print x
print y

print "I said: %r." % x
print "I also said: '%s'." % y

hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"

print joke_evaluation % hilarious

w = "This is the left side of..."
e = "a string with a right side."

print w + e

Python Printing

We will now use Python printing to just type in code and let it run. We have already discussed this subject in detail because it is essentially the same.

print "Mary had a little lamb."
print "Its fleece was white as %s." % 'snow'
print "And everywhere that Mary went."
print "." * 10 # what'd that do?

end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"

# watch that comma at the end. try removing it to see what happens
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
formatter = "%r %r %r %r"

print formatter % (1, 2, 3, 4)
print formatter % ("one", "two", "three", "four")
print formatter % (True, False, False, True)
print formatter % (formatter, formatter, formatter, formatter)
print formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
Here's some new strange stuff, remember type it exactly.

days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"

print "Here are the days: ", days
print "Here are the months: ", months

print """
There's something going on here.
With the three double- quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
"""

 

Online Training Tutorials

  • SAP Authorized Education Partners in IndiaSAP Authorized Education Partners in IndiaEvery sap professional want to know list of SAP Authorized Education Partners in India, There is some list of sap certified training center and education partners. These institutes give […]
  • sap projectWhat is SAP Project?When a company decides to implement selected modules of SAP ECC then that marks the start of an implementation project. A project manager is assigned to the SAP project who manages the […]
  • Business IntelligenceWhat is Business Intelligence?Business Intelligence: The Purpose of Business Intelligence, During all business activities, companies create data. In all departments of the company, employees at all levels use this data […]
  • C Program to Find Total of Even IntegersC Arrays with ExamplesC Arrays are convenient way of grouping lot of variables under single variable name. Arrays they can be one dimensional, two dimensional or more dimensional! An array is defined using […]
  • C Program to Find Total of Even IntegersC Program to Convert Temperature From Fahrenheit to CelsiusThis C program converts the given temperature in Fahrenheit to Celsius using the following conversion formula and explain with simple steps, Temperature measurement in today’s […]
  • sap interview questionsSAP Interview Questions and Answers – Technosapwe have listed some of most common SAP Interview questions and Answers are listed below, along with insights from several recruitment professionals about how to answer. As part of your SAP […]
  • C Program to Find Total of Even IntegersC – If else Statement with ExamplesThe if else statement is used to express decisions and the syntax as per below, if (expression) statement 1 else statement 2 where the else part is optional. The expression is […]
  • Material Ledger Multiple CurrencyHow to do Material Ledger Multiple Currency?Material Ledger Multiple Currency: The system stores valuation data for a material in its material ledger in up to three currencies. You specify in which currencies the system stores this […]