Computer Science, asked by lalithkishore4360, 10 months ago

Write the output of the following code.
#!/usr/bin/python
str = "this is string example….wow!!!"
print str.ljust(50, ‘0’)

Answers

Answered by letmeanswer12
0

The output is - this is string example....wow!!!000000000000000000

Explanation:

The Python string method ljust() returns the string with left-justified in a string of length width. The specified fillchar is used for padding of the string and space is used as a default. If the width is less than the length of the string then the original string is returned.

In the given problem,

  • str = "this is string example….wow!!!"
  • str.ljust(50, ‘0’)  

The original string length is 32 chrs and the remaining 18 chrs will be filled up with '0' to give total length 50.

  • So the output is -
  • this is string example....wow!!!000000000000000000

Similar questions
Math, 1 year ago