First Python Program¶
In [1]:
print("www.machinelearning.org.in")
In [2]:
print("Python")
print("Data Science")
print("Machine Learning")
Single Line Comment¶
Comments start with a #, and Python will render the rest of the line as a comment:
In [5]:
print("Hello") #This is a comment
In [3]:
print("Python")
print("Data Science")
#print("Machine Learning")
print("Deep Learnig")
print("Artificial Intelligence")
Multiline Comment¶
Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it:
In [4]:
'''
print("Python")
print("Data Science")
print("Machine Learning")
print("Deep Learnig")
'''
print("Artificial Intelligence")
Assign Value to a variable¶
In [9]:
a=10
b=3.134
c="Machine Learning"
In [10]:
print(a)
print(b)
print(c)
In [11]:
print("Value of a :",a)
print("Value of b :",b)
print("Value of c :",c)
In [12]:
print(a,b,c)
In [13]:
print("Value of a :",a,"Value of b :",b,"Value of c :",c)
In [14]:
print("Value of a :",a,"\nValue of b :",b,"\nValue of c :",c)
In [15]:
print("Value of a :",a,end='\n')
print("Value of b :",b,end='\n')
print("Value of c :",c,end='\n')
In [17]:
print("Value of a :",a,end=' ')
print("Value of b :",b,end=' ')
print("Value of c :",c,end=' ')
Accepting User Inputs¶
input( ) accepts input and stores it as a string. Hence, if the user inputs a integer, the code should convert the string to an integer and then proceed.
In [18]:
a=input("Enter any value:")
print(a)
In [19]:
print(type(a))
Note that type( ) returns the format or the type of a variable or a number