|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "_Aufgabe 1_\n",
- "\n",
- "Schreiben Sie ein Python-Programm, das drei Zahlen von der Tastatur einliest und anschließend die\n",
- "größte von ihnen ausgibt."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "slideshow": {
- "slide_type": "-"
- }
- },
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "pycharm": {
- "is_executing": false,
- "name": "#%%\n"
- },
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "outputs": [],
- "source": [
- "num1 = float(input(\"Erste Zahl:\"))\n",
- "num2 = float(input(\"Zweite Zahl:\"))\n",
- "num3 = float(input(\"Dritte Zahl:\"))\n",
- "\n",
- "maximum = num1 if num1 > num2 else num2\n",
- "maximum = maximum if maximum > num3 else num3\n",
- "print(maximum) \n",
- "\n",
- "\n",
- "if num1 > num2:\n",
- " if num1 > num3:\n",
- " print(num1)\n",
- " else:\n",
- " print(num3)\n",
- "else:\n",
- " if num2 > num3:\n",
- " print(num2)\n",
- " else:\n",
- " print(num3)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "_Aufgabe 2_\n",
- "\n",
- "Schreiben Sie ein Python-Programm, das zwei Zahlen von der Tastatur einliest. Anschließend soll\n",
- "nachgefragt werden, ob die beiden Zahlen addiert, subtrahiert, mulitpliziert oder dividiert werden sollen. \n",
- "Führen Sie die gewünschte Operation aus und geben Sie das Ergebnis aus. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "slideshow": {
- "slide_type": "-"
- }
- },
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "pycharm": {
- "name": "#%%\n"
- },
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "outputs": [],
- "source": [
- "num1 = float(input(\"Erste Zahl:\"))\n",
- "num2 = float(input(\"Zweite Zahl:\"))\n",
- "\n",
- "op = input(\"Was soll gemacht werden (+,-,*,/):\")\n",
- "if op == \"+\":\n",
- " erg = num1 + num2\n",
- "elif op == \"-\":\n",
- " erg = num1 - num2\n",
- "elif op == \"*\":\n",
- " erg = num1 * num2\n",
- "elif op == \"/\":\n",
- " erg = num1 / num2\n",
- "else:\n",
- " erg = None\n",
- " \n",
- "print(f\"Unbekannter Operator <{op}>.\") if erg is None else print(f\"{num1} {op} {num2} = {erg}\")"
- ]
- }
- ],
- "metadata": {
- "celltoolbar": "Slideshow",
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.9.9"
- },
- "pycharm": {
- "stem_cell": {
- "cell_type": "raw",
- "metadata": {
- "collapsed": false
- },
- "source": []
- }
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
- }
|