By Default data type of input function is String.
The split() method splits a string into a list.
sentence="My Name is vedika".split()
print(sentence)a,b=input("Enter two values").split()
print("a= ",a)
print("b= ",b)rate,quantity=input("Enter rate and quantity").split()
bill=int(rate)*int(quantity)
print("bill :",bill)c=float(input("Enter tempreture in celsius :"))
f=c*(9/5)+32
print("Temperature in Fahrenheit =",f)You can have a string split across multiple lines by enclosing it in triple quotes
poem="""
Twinkle, twinkle, little star,
How I wonder what you are.
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are!"""
print(poem)A slice object is used to specify how to slice a sequence. You can specify where to start the slicing, and where to end.
mystring="Road to Code"
print(mystring[0:4])mystring="Road to Code"
print(mystring[1:])mystring="Road to Code"
print(mystring[:8])len() is a built-in function in python. You can use the len() to get the length of the given string, array, list.
studentname="vedika"
print(len(studentname))studentname="vedika"
length=len(studentname)
print(length)The 'in' operator is used to check if a value exists in a sequence or not.
mystring="Road to Code"
print("Road" in mystring)mystring="Dahi Puri"
print("Pani" in mystring)1️⃣Write a Python program to find area of a rectangle.
💡 HINT: use formula area = length * breadth .
👁 Show Answer
a,b = input("Enter a length*breadth").split()
C =int(a)*int(b)
print("Area of rectangle =",C)
