You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

094 Uebung.ipynb 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {
  6. "pycharm": {
  7. "name": "#%% md\n"
  8. },
  9. "slideshow": {
  10. "slide_type": "slide"
  11. }
  12. },
  13. "source": [
  14. "\n",
  15. "Gegeben ist eine binäre Grafikdatei <code>ohm.png</code>."
  16. ]
  17. },
  18. {
  19. "cell_type": "code",
  20. "execution_count": null,
  21. "metadata": {
  22. "pycharm": {
  23. "name": "#%%\n"
  24. }
  25. },
  26. "outputs": [],
  27. "source": [
  28. "from IPython.display import Image\n",
  29. "Image(filename=\"ohm.png\")"
  30. ]
  31. },
  32. {
  33. "cell_type": "markdown",
  34. "metadata": {
  35. "pycharm": {
  36. "name": "#%% md\n"
  37. },
  38. "slideshow": {
  39. "slide_type": "slide"
  40. }
  41. },
  42. "source": [
  43. "_Aufgabe 1_\n",
  44. "\n",
  45. "Erstellen Sie ein Python-Programm, dass diese Datei in eine zweite\n",
  46. "Datei <code>logo.png</code> kopiert. Übertragen Sie die Daten bitte\n",
  47. "in 32 Byte Paketen."
  48. ]
  49. },
  50. {
  51. "cell_type": "code",
  52. "execution_count": null,
  53. "metadata": {},
  54. "outputs": [],
  55. "source": []
  56. },
  57. {
  58. "cell_type": "code",
  59. "execution_count": null,
  60. "metadata": {
  61. "pycharm": {
  62. "name": "#%%\n"
  63. },
  64. "slideshow": {
  65. "slide_type": "slide"
  66. }
  67. },
  68. "outputs": [],
  69. "source": [
  70. "from IPython.display import Image\n",
  71. "\n",
  72. "\n",
  73. "with open(\"ohm.png\", \"rb\") as source_file:\n",
  74. " with open(\"logo.png\", \"wb\") as dest_file:\n",
  75. " buffer_size = 32\n",
  76. " buffer = source_file.read(buffer_size)\n",
  77. " while len(buffer)>0:\n",
  78. " dest_file.write(buffer)\n",
  79. " buffer = source_file.read(buffer_size)\n",
  80. "\n",
  81. "\n",
  82. "Image(filename=\"logo.png\")"
  83. ]
  84. }
  85. ],
  86. "metadata": {
  87. "celltoolbar": "Slideshow",
  88. "kernelspec": {
  89. "display_name": "Python 3 (ipykernel)",
  90. "language": "python",
  91. "name": "python3"
  92. },
  93. "language_info": {
  94. "codemirror_mode": {
  95. "name": "ipython",
  96. "version": 3
  97. },
  98. "file_extension": ".py",
  99. "mimetype": "text/x-python",
  100. "name": "python",
  101. "nbconvert_exporter": "python",
  102. "pygments_lexer": "ipython3",
  103. "version": "3.9.9"
  104. }
  105. },
  106. "nbformat": 4,
  107. "nbformat_minor": 1
  108. }