The following code is completed in the interactive interface (you can also write the code into the script, you need to add print(...) to display):
The interactive command prompt of python is:
The content entered after this symbol will run in real time and display the results of the run.
For example, if we enter 2 it will produce the following changes:
We enter 2, and python reads 2 as a number, and then returns the entered number, which is 2.
What if we enter a Formula?
Python will calculate the corresponding value.
Python contains algorithms that can perform scientific calculations. For example, if you enter:
>>> 7+3*7/5+5/3+(11*9+2)/5
33.06666666666666
>>>
Python will perform operations based on the priority of arithmetic symbols.
Python can also directly perform large number operations, you can calculate any number less than 1e10000:
>>> 2**2
4
>>> 2**3
8
>>> 2**4
16
>>> 2**5
32
>>> 2**6
64
>>> 2**100
1267650600228229401496703205376
>>> 2**1000
107150860718626732094842504906000181056140481170553360744375
038837035105112493612249319837881569585812759467291755314682
518714528569231404359845775746985748039345677748242309854210
746050623711418779541821530464749835819412673987675591655439
460770629145711964776865421676604298316526243868372056680693
76
>>> 2**10000
199506311688075838488374216268358508382349683188619245485200
894985294388302219466319199616840361945978993311294232091242
715564913494137811175937859320963239578557300467937945267652
465512660598955205500869181933115425086084606181046855090748
660896248880904898948380092539416332578506215683094739025569
123880652250966438744410467598716269854532228685381616943157
756296407628368807607322285350916414761839563814589694638994
108409605362678210646214273333940365255656495306031426802349
694003359343166514592977732796657756061725820314079941981796
073782456837622800373028854872519008344645814546505579296014
148339216157345881392570953797691192778008269577356744441230
620187578363255027283237892707103738028663930314281332414016
241956716905740614196543423246388012488561473052074319922596
117962501309928602417083408076059323201612684922884962558413
128440615367389514871142563151110897455142033138202029316409
575964647560104058458415660720449628670165150619206310041864
222759086709005746064178569519114560550682512504060075198422
618980592371180544447880729063952425483392219827074044731623
767608466130337787060398034131971334936546227005631699374555
082417809728109832913144035718775247685098572769379264332215
993998768866608083688378380276432827751722736575727447841122
943897338108616074232532919748131201976041782819656974758981
645312584341359598627841301281854062834766490886905210475808
826158239619857701224070443305830758690393196046034049731565
832086721059133009037528234155397453943977152574552905102123
109473216107534748257407752739863482984983407569379556466386
218745694992790165721037013644331358172143117913982229838458
473344402709641828510050729277483645505786345011008529878123
894739286995408343461588070439591189858151457791771436196987
281314594837832020814749821718580113890712282509058268174362
205774759214176537156877256149045829049924610286300815355833
081301019876758562343435389554091756234008448875261626435686
488335194637203772932400944562469232543504006780272738377553
764067268986362410374914109667185570507590981002467898801782
719259533812824219540283027594084489550146766683896979968862
416363133763939033734558014076367418777110553842257394991101
864682196965816514851304942223699477147630691554682176828762
003627772577237813653316111968112807926694818872012986436607
685516398605346022978715575179473852463694469230878942659482
170080511203223654962881690357391213683383935917564187338505
109702716139154395909915981546544173363116569360311222499379
699992267817323580231118626445752991357581750081998392362846
152498810889602322443621737716180863570154684840586223297928
538756234865564405369626220189635710288123615675125433383032
700290976686505685571575055167275188991941297113376901499161
813151715440077286505731895574509203301853048471138183154073
240533190384620840364217637039115506397890007428536721962809
034779745333204683687958685802379522186291200807428195513179
481576244482985184615097048880272747215746881315947504097321
150804981904558034168269497871413160632106863915116817743047
92596709376
>>>
Where ** means to calculate the power.
We can use the type() function to observe the data type:
>>> type(2)
<class 'int'>
>>>
2 is an integer.
There are six data types in Python: Numbers, strings, lists, tuples, sets, dictionaries. Let's explain each data type in next a few chapter.
Classified according to whether it contains a hash table
Numbers, strings, lists, tuples do not use hash table indexes.
sets, dictionaries use hash table index.
When introducing the data structure, we will use whether to include a hash table to introduce separately.
Numbers, strings, tuples are immutable.
lists, sets, dictionaries are variable.
I will talk about the difference between Variable and Immutable in a later chapter.
Statistics
Start time of this page: December 18, 2021
Completion time of this page: December 18, 2021