Introduction to Python Programming Language
What is Python?
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
artificial intelligence
big data
web development (server-side)
software development
mathematics
system scripting
First Python Program
print("www.machinelearning.org.in")
print("Python")
print("Data Science")
print("Machine Learning")
Python
Data Science
Machine Learning
Single Line Comment
Comments start with a #, and Python will render the rest of the line as a comment:
'print("Hello") #This is a comment'
Hello
'print("Python")
print("Data Science")
#print("Machine Learning")
print("Deep Learnig")
print("Artificial Intelligence")'
Python
Data Science
Deep Learnig
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:
'''
print("Python")
print("Data Science")
print("Machine Learning")
print("Deep Learning")
'''
print("Artificial Intelligence")
Artificial Intelligence
Assign Value to a variable
a=10
b=3.134
c="Machine Learning"
print(a)
print(b)
print(c)
10
3.134
Machine Learning
print("Value of a :",a)
print("Value of b :",b)
print("Value of c :",c)
Value of a : 10
Value of b : 3.134
Value of c : Machine Learning
print(a,b,c)
3.134 Machine Learning
print("Value of a :",a,"Value of b :",b,"Value of c :",c)
Value of a : 10 Value of b : 3.134 Value of c : Machine
Learning
print("Value of a :",a,"\nValue of b :",b,"\nValue of c
:",c)
Value of a : 10
Value of b : 3.134
Value of c : Machine Learning
print("Value of a :",a,end='\n')
("Value of b :",b,end='\n')
print("Value of c :",c,end='\n')
Value of a : 10
Value of b : 3.134
Value of c : Machine Learning
print("Value of a :",a,end=' ')
print("Value of b :",b,end=' ')
print("Value of c :",c,end=' ')
Value of a : 10 Value of b : 3.134 Value of c : Machine
Learning
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.
a=input("Enter any value:")
print(a)
Enter any value:Machine Learning
Machine Learning
print(type(a))
< class 'str' >
Note that type( ) returns the format or the type of a variable or a number
Top comments (0)