Arithmetic operators: Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.
OPERATOR
DESCRIPTION
SYNTAX
+
Addition: adds two operands
x + y
–
Subtraction: subtracts two operands
x – y
*
Multiplication: multiplies two operands
x * y
/
Division (float): divides the first operand by the second
x / y
//
Division (floor): divides the first operand by the second
x // y
%
Modulus: returns the remainder when first operand is divided by the second
x % y
**
Power : Returns first raised to power second
x ** y
Example:
for example, open any of your text editor(notepad/notepad++), then copy the code below
a = 9
b = 4
#Addition of numbers
add = a + b
#Subtraction of numbers
sub = a - b
#Multiplication of number
mul = a * b
#Division(float) of number
div1 = a / b
#Division(floor) of number
div2 = a // b
#Modulo of both number
mod = a % b
#Power
p = a ** b
print results
print(add)
print(sub)
print(mul)
print(div1)
print(div2)
print(mod)
print(p)
Save this file with test.py, then search your Command Prompt (.cmd) in your windows, open it, then type: python test.py, or python3 test.py.
Developers often have a need to interact with users, either to get data or to provide some sort of result. Most programs today use a dialog box as a way of asking the user to provide some type of input. While Python provides us with two inbuilt functions to read the input from the keyboard.
input ( type your input here)
raw_input ( type your input here )
input ( ) : This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether user entered a string or a number or list. If the input provided is not correct then either syntax error or exception is raised by python. For example:
Các nhà phát triển thường có nhu cầu tương tác với người dùng, để lấy dữ liệu hoặc cung cấp một số loại kết quả. Hầu hết các chương trình ngày nay đều sử dụng hộp thoại như một cách để yêu cầu người dùng cung cấp một số kiểu đầu vào.
Trong khi Python cung cấp cho chúng ta hai hàm có sẵn để đọc đầu vào từ bàn phím.
input (lời nhắc)
raw_input (lời nhắc) input ():
Hàm này trước tiên lấy đầu vào từ người dùng và sau đó đánh giá biểu thức, có nghĩa là Python tự động xác định xem người dùng đã nhập một chuỗi hay một số hoặc danh sách. Nếu đầu vào được cung cấp không chính xác thì một trong hai lỗi cú pháp hoặc ngoại lệ được đưa ra bởi python. Ví dụ :
Python program showing
a use of input()
val = input("Enter your value: ")
print(val)
In this book we will learn the basic about python before we go deeper into the Computer Vision project using Python, openCV, CNN to cars and lane on highway classification:
Below is the link to where you should go. Or you can go the the menu in home page=>Python=>input-output.