Tuesday, July 23, 2019

Print strings --- parts and whole

Script

#!/usr/local/bin/python3.4

gospel = 'Cricket is a game of uncertainties!!!'

print(gospel)                  # Prints complete gospel string
print(gospel[0])               # Prints first character of the gospel string
print(gospel[3:25])            # Prints characters starting from 3rd to 5th
print(gospel[5:])              # Prints gospeling starting from sixth character
print(gospel * 3)              # Prints gospel string three times
print(gospel + " Whattttt")    # Prints concatenated gospel string


Execution

Cricket is a game of uncertainties!!!
C
cket is a game of unce
et is a game of uncertainties!!!
Cricket is a game of uncertainties!!!Cricket is a game of uncertainties!!!Cricket is a game of uncertainties!!!
Cricket is a game of uncertainties!!! Whattttt

No comments:

Post a Comment