In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the operators of Python full stack". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "What are the operators of Python's full stack"!
1. Arithmetic_Compare_Assign_Member 1.1 Arithmetic Operators
Arithmetic operator: + - * / // % **
# +var1 = 7var2 = 90res = var1 + var2print(res)# -var1 = 7var2 = 90res = var1 - var2print(res)# *var1 = 7var2 = 10res = var1 * var2print(res)# /The result is always fractional var1 = 10var2 = 5res = var1 / var2print (res , type(res))# //floor divide "" dividend divisor = quotient """" Note: If dividend or divisor is decimal, then the value is followed by.0 to decimal ""var1 = 10.0var2 = 3.0# var2 = 3.0res = var1 // var2print(res)# % remainder var1 = 7var2 = 4res = var 1% var2res =-7% 4 # -3 + (-4) = -1res =-7%-4 # -3 (dividend and divisor are negative, normal results are signed)res = 81% 7 # 4res = 81%-7 # -3res =-81% 7 # 3res =-81%-7 # -4print(res)# ** exponentiation res = 2 ** 3print(res)1.2 comparison operator
Comparison operator: >
< >= 5res = 10 >= 10# == This symbol is for comparison, compare == whether the values on both sides are the same res = 5 == 9res = 5 != 9 print(res)1.3 Assignment operators
Assignment operator: = += -= *= /= //= %= **=
# = assignment operator assigns the right value to the left variable a = 5 5res = (5 or 6) and 7 # 5 and 7res = not (5 or 6) and 7 # not 5 and 7 => False and 7 => Falseres = 14 and 5 ~
var1 = 19var2 = 15# & bitwise vs res = var1 & var2"""000... 10011000 ... 01111000 ... 00011 => 3"""print(res)# |By bit or res = var1| var2"""000 ... 10011000 ... 01111000 ... 11111"""print(res)# ^bitwise XOR""" two values are different =>True otherwise returns False""res = var1 ^ var2"" 000... 10011000 ... 01111000 ... 11100""print(res)# > right shift (equivalent to division)""5 floor divided by 2 to the nth power ""res = 5 >> 1 # 2res = 5 >> 2 # 1res = 5 >> 3 # 0""000... 101000 ... 010 => 2000 ... 001 => 1000 ... 000 => 0"""print(res)# ~ bitwise NOT (operates on complement, bitwise negates, includes every bit)"" -(n+1) ""# res = ~22res = ~19print(res)""" Original code:000... 10011 Reverse:000... 10011 complement:000... 10011's complement: 000 ... 10011 By Bit Non: 111... 01100 gives you complement-> original complement:111... 01100 Inverse:100... 10011 Original Code:100... 10100 => -20"""res = ~-19print(res)""" Original Code:100... 10011 Reverse:111... 01100 complement:111... 01101's complement: 111 ... 01101 By Bit Non: 000... 10010 gives you complement-> original code (because it is an integer, the original complement is the same)000... 10010 => 18"""3.2 Summary Summary: Individual operators: Operator with highest priority: ** Lowest priority operator: = () can be upgraded to priority Unary operators> Binary operators (precedence) Unary operators: operate on a value ~ -at the same time Binary operators: operate on a value + - * /... at the same time. Same Kind Operator: Arithmetic operators: multiplication> addition Logical operators: () > not > and > or bitwise operators : ( > ) > & > ^ > | Overall sorting: Arithmetic operators> Bitwise operators> Comparison operators> Identity operators> Membership operators> Logical operators Assignment operator used for closing """res = 5+5 1 3).0 or 5 > 4 4).5
< 4 or 3 5).2 >1 or 6 6).3 and 2 > 1 7).0 and 3 > 1 8).2 > 1 and 3 9).3 > 1 and 0 10).3 > 1 and 2 or 2
< 3 and 3 and 4 or 3 >2 11)not 2 > 1 and 3
< 4 or 4 >5 and 2 > 1 and 9 > 8 or 7 < 69. Prompt the user to enter "How to become stronger in dnf? ". If the input is to charge money, print "Ma Huateng loves you" , on the contrary, the output,"You think about it, how can it become stronger without charging money" At this point, I believe that everyone has a deeper understanding of "What are the operators of Python's full stack", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.