Αρνητικοί αριθμοί

Ξεκίνησε από socnafs, 23 Σεπ 2017, 08:26:35 ΜΜ

« προηγούμενο - επόμενο »

socnafs

-8/3 αποτελεσμα -3 Πως προκυπτει?

>>>a='epal'
>>>a
αποτελεσμα 'epal'
>>>print a
αποτελεσμα epal

Πως προκυπτει η διαφορα?

taxata

#1
python 2.x
-8/3: -8, 3 είναι ακέραιοι και εκτελείται "ακέραια" διαίρεση με floor division ... μετακίνηση στον αριστερό ακέραιο
-8/3 = -3
+8/3 = 2
αλλιώς -8/3.0 = -8/float(3) = -8.0/3 = -2.6666666666666665
τα υπόλοιπα είναι python string stuff για να ξέρεις ότι η μεταβλητή είναι string με την print δεν μπορείς να το δεις
>>>x = "123"
>>>x
"123" και όχι 123
>>>print x
123
και εάν εξακολουθεί να σου φαίνεται περίεργο δοκίμασε αυτό για να το ξεχάσεις
>>>0.1 + 0.1 + 0.1
>>>print 0.1 + 0.1 + 0.1  ;D
Τάσος_Χατζηπαπαδόπουλος
Κύριε δεν έχω internet
http://users.sch.gr/chatzipap/

dpa2006

Computer science (abbreviated CS or CompSci) is the scientific and practical approach to computation and its applications. It is the systematic study of the feasibility, structure, expression, and mechanization of the methodical processes (or algorithms) that underlie the acquisition, representation, processing, storage, communication of, and access to information, whether such information is encoded in bits and bytes in a computer memory or transcribed engines and protein structures in a human cell.source:http://en.wikipedia.org/wiki/Computer_science