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.

021a Uebung.ipynb 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {
  6. "slideshow": {
  7. "slide_type": "slide"
  8. }
  9. },
  10. "source": [
  11. "_Aufgabe 1_\n",
  12. "\n",
  13. "Schreiben Sie ein Python-Programm, das drei Zahlen von der Tastatur einliest und anschließend die\n",
  14. "größte von ihnen ausgibt."
  15. ]
  16. },
  17. {
  18. "cell_type": "code",
  19. "execution_count": null,
  20. "metadata": {
  21. "slideshow": {
  22. "slide_type": "-"
  23. }
  24. },
  25. "outputs": [],
  26. "source": []
  27. },
  28. {
  29. "cell_type": "code",
  30. "execution_count": null,
  31. "metadata": {
  32. "pycharm": {
  33. "is_executing": false,
  34. "name": "#%%\n"
  35. },
  36. "slideshow": {
  37. "slide_type": "slide"
  38. }
  39. },
  40. "outputs": [],
  41. "source": [
  42. "num1 = float(input(\"Erste Zahl:\"))\n",
  43. "num2 = float(input(\"Zweite Zahl:\"))\n",
  44. "num3 = float(input(\"Dritte Zahl:\"))\n",
  45. "\n",
  46. "maximum = num1 if num1 > num2 else num2\n",
  47. "maximum = maximum if maximum > num3 else num3\n",
  48. "print(maximum) \n",
  49. "\n",
  50. "\n",
  51. "if num1 > num2:\n",
  52. " if num1 > num3:\n",
  53. " print(num1)\n",
  54. " else:\n",
  55. " print(num3)\n",
  56. "else:\n",
  57. " if num2 > num3:\n",
  58. " print(num2)\n",
  59. " else:\n",
  60. " print(num3)"
  61. ]
  62. },
  63. {
  64. "cell_type": "markdown",
  65. "metadata": {
  66. "slideshow": {
  67. "slide_type": "slide"
  68. }
  69. },
  70. "source": [
  71. "_Aufgabe 2_\n",
  72. "\n",
  73. "Schreiben Sie ein Python-Programm, das zwei Zahlen von der Tastatur einliest. Anschließend soll\n",
  74. "nachgefragt werden, ob die beiden Zahlen addiert, subtrahiert, mulitpliziert oder dividiert werden sollen. \n",
  75. "Führen Sie die gewünschte Operation aus und geben Sie das Ergebnis aus. "
  76. ]
  77. },
  78. {
  79. "cell_type": "code",
  80. "execution_count": null,
  81. "metadata": {
  82. "slideshow": {
  83. "slide_type": "-"
  84. }
  85. },
  86. "outputs": [],
  87. "source": []
  88. },
  89. {
  90. "cell_type": "code",
  91. "execution_count": null,
  92. "metadata": {
  93. "pycharm": {
  94. "name": "#%%\n"
  95. },
  96. "slideshow": {
  97. "slide_type": "slide"
  98. }
  99. },
  100. "outputs": [],
  101. "source": [
  102. "num1 = float(input(\"Erste Zahl:\"))\n",
  103. "num2 = float(input(\"Zweite Zahl:\"))\n",
  104. "\n",
  105. "op = input(\"Was soll gemacht werden (+,-,*,/):\")\n",
  106. "if op == \"+\":\n",
  107. " erg = num1 + num2\n",
  108. "elif op == \"-\":\n",
  109. " erg = num1 - num2\n",
  110. "elif op == \"*\":\n",
  111. " erg = num1 * num2\n",
  112. "elif op == \"/\":\n",
  113. " erg = num1 / num2\n",
  114. "else:\n",
  115. " erg = None\n",
  116. " \n",
  117. "print(f\"Unbekannter Operator <{op}>.\") if erg is None else print(f\"{num1} {op} {num2} = {erg}\")"
  118. ]
  119. }
  120. ],
  121. "metadata": {
  122. "celltoolbar": "Slideshow",
  123. "kernelspec": {
  124. "display_name": "Python 3 (ipykernel)",
  125. "language": "python",
  126. "name": "python3"
  127. },
  128. "language_info": {
  129. "codemirror_mode": {
  130. "name": "ipython",
  131. "version": 3
  132. },
  133. "file_extension": ".py",
  134. "mimetype": "text/x-python",
  135. "name": "python",
  136. "nbconvert_exporter": "python",
  137. "pygments_lexer": "ipython3",
  138. "version": "3.9.9"
  139. },
  140. "pycharm": {
  141. "stem_cell": {
  142. "cell_type": "raw",
  143. "metadata": {
  144. "collapsed": false
  145. },
  146. "source": []
  147. }
  148. }
  149. },
  150. "nbformat": 4,
  151. "nbformat_minor": 1
  152. }