Basic programs of python

 Program to print hello world

print("hello world")
output:











program to illustrate commenting  in python
# hy i'm vishal rana
'''this is multiline
comment
i can use multiple lines and write anything'''
print("hello world")
output

program to illusrtate input 
a = int(input("enter the value of a"))
print(a)

Output: 

program to illustrate the variable and datatypes;
a = "vishal" #string
b= 34 # integer
c = 34.5 #float
d = True #boolean
f = None # null value 0r 0
# printing the values of variables
print (a)
print (b)
print (c)
print (d)
print (f)

#printing the type of variables

print (type(a))
print (type(b))
print (type(c))
print (type(d))
print (type(f))
Output
















program  to typecast datatypes

a = "434"
print("before conversion ", type(a))
a = int(a)
print("after conversion", type(a))

#converted the type of variable forcefully
Output























/

No comments:

Post a Comment