当前位置:网站首页>4.6 floating point number
4.6 floating point number
2022-06-30 15:15:00 【Andy Python learning notes】
4.6 Floating point numbers
Python The first data type : character string , Shorthand for str.
Python The second data type : Integers , The whole number is in English integer, Shorthand int.
Python The third data type : Floating point numbers , The English name of a floating-point number is float, There is no shorthand for floating-point numbers .
float [fləʊt]: Floating point numbers .
Python Numbers without dots in are integers , Some numbers are floating point numbers .
The following numbers are floating point numbers .
a = 0.5
b = -0.5
c = 1.0
# Find the sum of two floating-point numbers
0.2+0.2
【 Terminal output 】
0.4
# Find the sum of two floating-point numbers
0.2+0.1
【 Terminal output 】
0.30000000000000004
# Find the product of two floating-point numbers
0.2*0.2
【 Terminal output 】
0.04000000000000001
# Find the product of two floating-point numbers
2*0.2
【 Terminal output 】
0.4
Floating point calculation :
# Assign a value to a variable
float_1 = 0.55
float_2 = 0.3
# Find the sum of two floating-point numbers
print(float_1+float_2)
【 Terminal output 】
0.8500000000000001
0.5+0.33 And why not 0.85 Well ?
As we all know, the operation of the computer is binary , Before the operation , The computer will first 0.55 and 0.3 Convert to binary , So the tail of the calculated value is one more 1.
This is not Python Key points of , Understanding can .0.55( Decimal system ) = 0.1000110011001100110011001100110011001100110011001101( Binary system )0.3( Decimal system ) = 0.0100110011001100110011001100110011001100110011001101( Binary system )
Exercises :
ask : Please tell me the following three data 【100】、【‘100’】、【100.0】 The data types are :
answer : Integers 、 character string 、 Floating point numbers .
summary
1、Python The first data type : character string ,str.
2、Python The second data type : Integers ,int.
3、Python The third data type : Floating point numbers ,float.
边栏推荐
- 1031 Hello world for u (20 points)
- Anyrtc implements application scenarios based on webrtc
- 1066 root of AVL tree (25 points)
- Programming exercises: special numbers (problem solving ideas + code implementation)
- 1107 social clusters (30 points)
- CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
- Quick sort (C language)
- Kubernetes: a comprehensive analysis of container choreography
- How to program and process such parts?
- Working principle and fault treatment of cutting cylinder in CNC machining center
猜你喜欢

How to do a good job in high concurrency system design? I have summarized three points

How does sd-rtn ensure the high availability of RTE services after infrastructure failure

Voice codec based on machine learning Agora silver: support high quality voice interaction at ultra-low bit rate

Scattered knowledge of C language (unfinished)

Anyrtc implements application scenarios based on webrtc
![[matlab] 3D drawing summary](/img/57/05156340ccdd79b866c4df955b3713.jpg)
[matlab] 3D drawing summary

Review 2021, embrace change and live up to Shaohua

Webrtc: industrial application based on Internet of things

Some reference routines for cache update

Svn password forgetting solution
随机推荐
Working principle and fault treatment of cutting cylinder in CNC machining center
How to program and process such parts?
1018 public bike Management (30 points)
[matlab] 2D drawing summary
Matlab finds prime numbers within 100
E - highways (minimum spanning tree)
Technology sharing | anyrtc service single port design
Teach you a learning method to quickly master knowledge
文本匹配——【NAACL 2022】GPL
Preliminary study on AI noise reduction evaluation system of sound network
左旋梯形螺纹的编程
Distributed -- openresty+lua+redis
1058 a+b in Hogwarts (20 points)
A little idea about big experiment data
Summary of C language interview questions
On which platform is it safer to buy Treasury reverse repo?
机械工程师面试的几个问题,你能答上来几个?
CCF window (Full Score code + problem solving idea) March 2, 2014
The sound network has fully opened the real-time transmission network sd-rtn, which has been free of network wide accidents for seven years - this is FPA!
RTC monthly tabloid programming challenge ended successfully in June; Review of the first anniversary of sound network's listing