top of page

Multiple Assignment,String Operations,Printing with Python

  • Writer: Jino Shaji
    Jino Shaji
  • Jan 7, 2015
  • 1 min read

Updated: Jun 9, 2020

Multiple Assignment

•You can also assign to multiple names at the same time. 

>>> x, y = 2, 3

>>> x

2

>>> y

3


String Operations


•We can use some methods built-in to the string data type to 

perform some formatting operations on strings:

>>> “hello”.upper()

‘HELLO’

•There are many other handy string operations available.  Check 

the Python documentation for more.


Printing with Python


•You can print a string to the screen using “print.”

•Using the % string operator in combination with the print

 command, we can format our output text. 

>>> print  “%s xyz %d”  %  (“abc”, 34)

abc xyz 34

  “Print” automatically adds a newline to the end of the string.  

If you include a list of strings, it will concatenate them with a

space between them.


>>>print “abc” >>> print “abc”,“def”

abc  abc def


in python 3

   syntax is  print (“%s xyz %d”  %  (“abc”, 34))

Recent Posts

See All
Program to Create an investment report.

“””Program: investment.py Author: JINO SHAJI Compute an investment report. 1. The inputs are        starting investment amount       ...

 
 
 

Comentarios


bottom of page