In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how python uses binary operation to find the sum and difference of two numbers". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "how python uses binary operation to find the sum and difference of two numbers" can help you solve the problem.
The following is the use of functions in python to find the sum and difference of two numbers class Calculate: def-- init-- (self,number1 Number2) # receives two parameters self.number1 = number1 self.number2 = number2 def he (self): print ("and is:% d"% (self.number1 + self.number2)) # to format the output def cha (self): print ("difference is:% d"% (self.number1-self.number2)) result = Calculate (5) # pass two parameters result.he () result.cha () # call the function to evaluate
Add: python_ writes a function to find the sum of two integers, requiring that the +, -, *, / four operation symbols should not be used in the function body.
Look at the code to write a function to find the sum of two integers, requiring that the +, -, *, / four operation symbols should not be used in the function body.'' # using XOR and carry to solve # cannot be a positive number and a negative number # may be the reason why the integer type of python can be infinite, which causes the XOR operations of positive and negative numbers to become smaller negative numbers without overflow # after a try with Swift, you can still get the # #-coding:utf-8-*-# class Solution:# def Add of the bit operation addition operation of positive and negative numbers (self Num1, num2): # while num2:# sum = num1 ^ num2# carry = (num1 & num2) 31 = 0 else num1-4294967296 method-return num1 if num1
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.