Hey, My Name is Vaibhav Singh and let me help you in getting started with basic Python Language and Programmes. 

Note: To keep this post interesting till the end, I am skipping the theory part. Although I will be explaining each of the terms that will be used in the programme.

Lesson 1 (Understanding Language)

Software Required

You can learn making the following programmes using both offline and online compilers. PyCharm is one of the popularly known offline compiler. I will suggest to use OnlineGdb if you want to learn python using online compiler without installing any software on your Pc/laptop.

Arithmetic Operations

1) Addition

Suppose we have to make a simple Python Programme to get the addition of two given numbers. Following will be the steps to proceed:

  • Assign Number to variable 1
  • Assign Number to variable 2
  • Assign variable 3 to add variable 1 and variable 2
  • Print the Variable 3

Confusing? No problem! Let us understand this with an example.

Q- Make a Python programme to Add 15 + 10. 

Let us follow the above steps to solve this problem.

Step 1: Take a Variable “a” equal to 15

Step 2: Take a Variable “b” equal to 10

Step 3: Take a Variable “c” equal to “a+b”

Step 4: Print Variable “c”

Python Addition Programme

The Output you will get = 25

or Simplified Method can be, let variable “c” = 15 + 10 and then print the variable “c”.

Simplified Python Addition

Now you understand how one programme can be made with different methods. Also, we minimized the lines of coding.

2) Subtraction / Division and Multiplication

Similarly you can perform different arithmetic operations like Subtraction, Multiplication, Division using the same set of codes. You will need to replace “+” with any other arithmetic symbol like “-” for subtraction, “*” for multiplication, “/” for divide.

Q- Make a Program to find if number is Positive, Negative or Zero

a = int(input(“Enter A \n”))
if a > 0:
    print(“A is Positive”)
elif a==0:
    print(“A is equal to zero“)
else:
    print(“A is negative“)

STEP WISE EXPLANATION:

Step 1: Take Input from the user

To take Input from the user, we will use the function int(input(“Enter A \n”)) and will assign it to variable 1

a = int(input(“Enter A \n”))

Step 2: Use If and Else statement to determine whether number inserted by user is positive, negative or zero.

  • If A > 0, it will imply that A is positive.

if a > 0:
    print(“A is Positive”)

  • If A==0 imply that A is equal to zero. Here “==” stands for the equal symbol. We will use the Elif funtion which stands for “Else If”.

elif a==0:
    print(“A is equal to zero”)

  • If A < 0 implies that A is negative.

else:
    print(“A is negative“)

Learn More About Vaibhav