Variable advanced

#counter = 100 # An integer assignment
#miles = 1000.0 # A floating point
#name = "John" # A string
#print (counter)
#print (miles)
#print (name)

#counter, miles, name = 100, 100.0, "John"
#print (counter, miles, name)

#print ("My name is", name)

#names = input("Who are you?")
#print ("My name is", names)

str = "Hello World!"
print (str)               # Prints complete string
print (str[0])            # Prints first character of the string
print (str[2:5])          # Prints  characters starting from 3rd to 5th
print (str[2:])           # Prints string starting from 3rd character
print (str * 2)           # Prints string two times
print (str + "TEST")      # Prints concatenated string
print (str , "TEST")
print (str[0:5])

Comments

Popular posts from this blog

WAN Technology

LO3 - Know the features and functions of information systems

WDD - LO1 - MANAGE SECURE SITES