perators, Conditionals, input()

WBOY
Release: 2024-07-18 15:56:27
Original
790 people have browsed it

perators, Conditionals, input()

*arithmetic operators *

The six arithmetic operators in Python are: addition (+), subtraction (-), multiplication (), division (/), modulo (%), and exponentiation (*). These operators allow you to perform mathematical operations on numeric data types such as integers and floating-point numbers.

*comparison operators *

Comparison operators are used to compare two values:

==, !=, <=, >=, >, <.

Logical Operators..

Python logical operators are used to combine conditional statements, allowing you to perform operations based on multiple conditions.
and, or, not

Assignment Operators

Assignment operators are used to assign values to variables:

, +=, /=, *=, -=

Conditionals

Used to execute a block of code only if a specified condition is true.

if condition:
code block

Used to execute a block of code if the condition in the if statement is false.

`if condition:
code block

Else:

code block

`

Short for "else if", used to check multiple conditions.

`if condition:

Elif :

Else:
--`
input

Age=int (input ("Enter your age" ))

Input from input() is always a string; convert it using functions like int(), float(), str().

BODMAS

Brackets (Parentheses ()): Operations inside brackets are performed first.
Orders (Exponentiation **): Next, orders (exponents and roots).
Division and Multiplication (/, *, //, %): From left to right. • Addition and Subtraction (+, -): From left to right.

The above is the detailed content of perators, Conditionals, input(). For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!