Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
gf_informatik:zahlensysteme:binary_collection [2025-04-28 10:28] hofgf_informatik:zahlensysteme:binary_collection [2025-05-13 07:38] (aktuell) hof
Zeile 1: Zeile 1:
-## Binärzahlen mit Python+## Binärzahlen in Python: Bausteine
 <html><script type="module" src="https://bottom.ch/ksr/ed/bottom-editor.js"></script></html> <html><script type="module" src="https://bottom.ch/ksr/ed/bottom-editor.js"></script></html>
  
Zeile 131: Zeile 131:
 quotient = a // b quotient = a // b
 rest = a % b rest = a % b
 +print(quotient, rest)
 </bottom-editor></html> </bottom-editor></html>
  
Zeile 177: Zeile 178:
     result = ''                    # start with empty string     result = ''                    # start with empty string
     for digit in b:     for digit in b:
-        if digit = '1':            # if digit is a one...+        if digit == '1':            # if digit is a one...
             result = result + '0'  # ...append a zero             result = result + '0'  # ...append a zero
-        elif digit = '0':+        elif digit == '0':
             result = result + '1'  # otherwise append a one             result = result + '1'  # otherwise append a one
     return result     return result
  • gf_informatik/zahlensysteme/binary_collection.1745836131.txt.gz
  • Zuletzt geändert: 2025-04-28 10:28
  • von hof