Python variable types

                      Variables in Python










 >>>  Source-Code :

var1 = "I'm akash"
var2 = 69
var3 = 69.9
var4 = "Har Har Mahadev"
var5 = "108"
var6 = " 12"

print(id(var2))                                           # id executes the address of the variables
print(id(10))                                                 # 10 is an object where we can hold our data
print(var1 + "yo yo")
print(var1[5])
print(var1[0:4])
print(var4[0:8] + "mahadev")
print(var4[-1])
print(var4[-7:-1])
# print(type(var1))
print(type(var2))
print(type(var3))

# print(var1 + var2)                                  # We can't add string(str) and integer(int) at same time
print(var2 + var3)
print(var1 + var4)
print(var1 + var5)                                    #var5 is also an str because it is in double quotes
print(var5 + var6)                                  # It is also string

# for convert str into int we use this :-

print(int(var5)+ int(var6))                #Now it's print in the int form
print(10 * "Hello World\n")                #for printing str many times we use that function
print(10 * str(int(var5)+int(var6)))         #for printing int many  time we use this function



# Que : Accept two no. and display it's sum

# Ans :

print("Enter first no.")
n1 = input()
print("Enter second no.")
n2 = input()
print("Sum of these no. is:", int(n1)+int(n2))




>>>                                            Click Here for more Source-Codes



: ) if you have any doubt in Python variable types then Contact Us : )
Python variable types Python variable types Reviewed by Coding Guy on July 06, 2019 Rating: 5

No comments:

Powered by Blogger.