10 Basic Python Programs to Get Started With Your Python Course
You are here because, you just have taken your first step to learn the most popular Language Python. Python is widely used in Machine learning, Artificial Intelligence, Data Science, Data Analysis and Web Development.
Be it be any module you choose from the above, there should be your first step to get started with. Here are some basic programs to get start with Python and continue your learning.
Basic Python Program 1:
Addition of two numbers:
a = 6
b = 5
c = a+b
print ("The sum of two numbers is:",c)
Out put
The sum of two numbers is: 11
Basic Python Program 2:
Usage of format string
Definition and Usage
The format() method formats the specified value(s) and insert them inside the string's placeholder.
The placeholder is defined using curly brackets: {}. Read more about the placeholders here.
The format() method returns the formatted string.
# This program adds two numbers using format
num1 = 1.5
num2 = 6.3
# Add two numbers
sum = num1 + num2
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
Out put:
The sum of 1.5 and 6.3 is 7.8
Comments
0