Advertisement
rric

am_anfang_hallo

Oct 10th, 2023 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. # Am Anfang jedes Programmierkurses gibt's ein "Hallo, Welt!"-Programm
  2. # Copyright 2022, 2023 Roland Richter                  [Mu: Pygame Zero]
  3.  
  4. # Erzeuge ein rechteckiges 600×400 Fenster
  5. WIDTH = 600
  6. HEIGHT = 400
  7.  
  8. # Im folgenden Code ist (absichtlich) ein Fehler versteckt; du sollst
  9. # den Code richtig stellen -- aber nur innerhalb der ↓ / ↑ Zeilen!
  10. # ÄNDERE den Code so, dass das "Hallo, Welt!"-Programm uns alle begrüßt.
  11. # ↓---------↓---------↓---------↓---------↓---------↓---------↓
  12. hallo_welt = "Holla, welt?"
  13. # ↑---------↑---------↑---------↑---------↑---------↑---------↑
  14.  
  15. def draw():
  16.     # Setze den Hintergrund auf schwarz
  17.     screen.fill("black")
  18.  
  19.     # Begrüße alle in der Mitte des Fensters
  20.     screen.draw.text(hallo_welt, (300, 200))
  21.  
  22.  
  23. # HALT! Änderungen unter dieser Zeile sind verboten!
  24. # ↑---------↑---------↑---------↑---------↑---------↑---------↑
  25.  
  26. def fail_string(name, val, exp):
  27.     return "\n  " + name + " ist " + str(val) + "\n  sollte aber " + str(exp) + " sein"
  28.  
  29. assert hallo_welt == "Hallo, Welt!", fail_string("hallo_welt", hallo_welt, "Hallo, Welt!")
  30.  
  31.  
  32. # ----------------------------------------------------------------------
  33. # This program is free software: you can redistribute it and/or modify
  34. # it under the terms of the GNU General Public License as published by
  35. # the Free Software Foundation, either version 3 of the License, or
  36. # (at your option) any later version.
  37. #
  38. # This program is distributed in the hope that it will be useful,
  39. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  41. # GNU General Public License for more details.
  42. #
  43. # You should have received a copy of the GNU General Public License
  44. # along with this program.  If not, see <https://www.gnu.org/licenses/>.
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement