Skip to main content

Arithmetic operator in python| Python arithmetic operator| Arithmetic operator| Operators in python| python for beginner

Hello reader's, 
In this post you are going to see about Arithmetic operator in python





Arithmetic operator is basically performs four types of function that is Addition, Subtraction, Multiplication and Division. In this post you will see how you can perform these operations using python. To perform these operation you don't have to install any modules.
Addition :- 
In addition operation you are going to add two number using python, for adding two number you have to take input from user , to take input from user type the code given below- 
A = int(input("Enter number A: "))  This line of code is going to take first input from user and 
B = int(input("Enter another number B: "))  this line of code is going to take second input from user.
print("The addition of A and B is: ", A+B) This line code is going to add the numbers taken as a input from user and also going to print the output.
Subtraction :-  In subtraction you have to take input from user and subtract it, as previously done in addition we have take input from user to take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: "))  this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A-B) This line code is going to subtract the numbers taken as a input from user and also going to print the output.
Multiplication :-
 As we have done in addition and subtraction we have to take two input from user and multiply it and print the output.
To take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: "))  this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A*B) This line code is going to Multiply the numbers taken as a input from user and also going to print the output.
Division :-
 Now for the last time we have to take two input from user and perform the division operation .
To take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: "))  this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A/B) This line code is going to Divide (A/B) the numbers taken as a input from user and also going to print the output.






Code :- 
#Addition
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The addition of A and B is: ", A+B)

#Subtraction
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The subtraction of A and B is: ", A-B)

#Multiplication
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The Multiplication of A and B is: ", A*B)

#Division
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The Division of A and B is: ", A/B)

Comments

Popular posts from this blog

Android 13 features| Android 13 updates| Material You design| language Customizable| Android themes Privacy and security controls in Android 13| App Hibernation in Android 13| Adaptive Charging in Android 13| Android 13 release date| Android Beta Program| Latest Android version

 Android 13: What's New and Exciting? Android 13, codenamed Tiramisu, is the latest version of Google's mobile operating system that is expected to launch in late 2023. Android 13 promises to bring a host of new features and improvements to enhance the user experience, security, and performance of Android devices. In this blog post, we will take a look at some of the most anticipated features of Android 13 and how they will benefit users and developers alike. One of the biggest changes in Android 13 is the introduction of Material You, a new design language that adapts to the user's preferences, mood, and context. Material You allows users to customize their device's theme, colors, fonts, icons, and shapes according to their personal style and taste. Material You also changes dynamically based on the time of day, the wallpaper, the app, and the device mode. For example, if the user switches to dark mode, the system will automatically adjust the colors and brightness to ...

Define a function that computes the length of a given list or string| Python for beginner

 Python is a popular programming language that is widely used by developers and data scientists. One of the fundamental concepts in Python is functions, which are self-contained blocks of code that perform a specific task. In this blog post, we will discuss how to define a function that computes the length of a given list or string using Python. What is a Function? A function is a block of code that performs a specific task. Functions are self-contained and can be called from anywhere in a program. Functions are an essential part of Python and are used extensively in programming. Defining a Function in Python In Python, functions are defined using the 'def' keyword, followed by the name of the function, and a set of parentheses. The body of the function is indented and contains the code that performs the task. Here is an example of a function that computes the length of a given list: def compute_length(list):     length = 0     for item in list:     ...

Define a procedure histogram() that takes a list of integers and prints a histogram to the screen| Histogram procedure| printing histogram| Python histogram function| Python programming

  How to Visualize Data with Python: Defining a Procedure Histogram() When it comes to analyzing data, visualization is key. Being able to see the patterns and trends in your data can make all the difference in understanding it. Luckily, Python has a built-in function for creating histograms, which is a powerful tool for visualizing data. In this blog post, we'll define a procedure called histogram() that takes a list of integers and prints a histogram to the screen. Before we get into the nitty-gritty of the code, let's briefly discuss what a histogram is and why it's useful. A histogram is a graphical representation of a frequency distribution, which is essentially a way to show how often certain values occur in a dataset. It's a great way to get a quick sense of the shape of your data, including its range, distribution, and outliers. Now, let's dive into the code. Here's how you can define a procedure histogram() in Python: def histogram(int_list):     for i ...