diff --git a/huiswerk week4 -islam.ipynb b/huiswerk week4 -islam.ipynb new file mode 100644 index 0000000..2b05b38 --- /dev/null +++ b/huiswerk week4 -islam.ipynb @@ -0,0 +1,247 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Random Password\n", + "As a user, I want to use a program which can generate random password and display the result on user interface. So that I can generate my password for any application.\n", + "\n", + "Acceptance Criteria:\n", + "\n", + "Password length must be 10 characters long.\n", + "It must contain at least 2 upper case letter, 2 digits and 2 special symbols.\n", + "You must import some required modules or packages.\n", + "The GUI of program must contain at least a button and a label.\n", + "The result should be display on the password label when the user click the generate button." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "import string\n", + "num=string.digits\n", + "sembol=string.punctuation\n", + "letter_s=string.ascii_lowercase\n", + "letter_up=string.ascii_uppercase\n", + "alles=[num,sembol,letter_s,letter_up]\n", + "password=\"\"\n", + "for i in range (3):\n", + " password +=alles[0][random.randint(0,11)]\n", + "for i in range (3):\n", + " password +=alles[1][random.randint(0,11)]\n", + "for i in range (2):\n", + " password +=alles[2][random.randint(0,11)]\n", + "for i in range (2):\n", + " password +=alles[3][random.randint(0,11)] \n", + "print(\"Your password is = \",password) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2- Number Guessing Game\n", + "As a player, I want to play a game which I can guess a number the computer chooses in the range I chose. So that I can try to find the correct number which was selected by computer.\n", + "\n", + "Acceptance Criteria:\n", + "\n", + "Computer must randomly pick an integer from user selected a range, i.e., from A to B, where A and B belong to Integer.\n", + "Your program should prompt the user for guesses\n", + "if the user guesses incorrectly, it should print whether the guess is too high or too low.\n", + "If the user guesses correctly, the program should print total time and total number of guesses.\n", + "You must import some required modules or packages\n", + "You can assume that the user will enter valid input." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "while True:\n", + " flag=True\n", + " while flag:\n", + " numara=input(\"lutfen ust sinir bir numara girin:\")\n", + " \n", + " if numara.isdigit():\n", + " print(\"oyuna baslayalim..\")\n", + " numara=int(numara)\n", + " flag=False\n", + " \n", + " else:\n", + " print(\"Lutfen gecerli bir sayi girin!\")\n", + " secret=int(random.randint(1,numara))\n", + " tahmin=None\n", + " sayi=1\n", + " \n", + " while tahmin!=secret:\n", + " tahmin=input(\"Lutfen sayi girin 1 ile\"+str(numara)+\":\")\n", + " if tahmin.isdigit():\n", + " tahmin=int(tahmin)\n", + " secret=int(secret)\n", + " if tahminsecret:\n", + " print(\"sayiniz secret numaradan buyuk!Tekrar deneyin..\")\n", + " if tahmin==secret:\n", + " print(\"Basardiniz,Tebrikler!!\")\n", + " else:\n", + " print(\"Lutfen Tekrar numara girin!\")\n", + " sayi+=1\n", + " print(\"seferde:\",sayi,\"tahmin\") \n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " 3.Mis Calculator\n", + "As a user, I want to use a program which can calculate basic mathematical operations. So that I can add, subtract, multiply or divide my inputs.\n", + "\n", + "Acceptance Criteria:\n", + "\n", + "The calculator must support the Addition, Subtraction, Multiplication and Division operations.\n", + "Define four functions in four files for each of them, with two float numbers as parameters.\n", + "To calculate the answer, use math.ceil() and get the next integer value greater than the result\n", + "Create a menu using the print command with the respective options and take an input choice from the user.\n", + "Using if/elif statements for cases and call the appropriate functions.\n", + "Use try/except blocks to verify input entries and warn the user for incorrect inputs.\n", + "Ask user if calculate numbers again. To implement this, take the input from user Y or N" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Hangi islemi yapmak istersiniz?\")\n", + "print(\"1.Toplama\",\"2.Cikarma\",\"3.Bolme\",\"4.Carpma\")\n", + "while True:\n", + " Secim=input(\"Seciminiz Yazin:\")\n", + " sayi1=float(input(\"Lutfen bir tane kusurlu sayi girin:\"))\n", + "#if sayi1!=float :\n", + " # print(\"Lutfen kusurlu sayi girin!\")\n", + " sayi2=float(input(\"Lutfen 2.kusurlu sayiyi girin:\"))\n", + "\n", + "#if sayi2!=float : \n", + " # print(\"Lutfen kusurlu sayi girin!\")\n", + " if Secim==\"1\":\n", + " print(sayi1,\"+\",sayi2,\"=\",sayi1+sayi2)\n", + " elif Secim==\"2\":\n", + " print(sayi1,\"-\",sayi2,\"=\",sayi1-sayi2) \n", + " elif Secim==\"3\":\n", + " print(sayi1,\"/\",sayi2,\"=\",sayi1//sayi2)\n", + " elif Secim==\"4\":\n", + " print(sayi1,\"*\",sayi2,\"=\",sayi1*sayi2) \n", + " else:\n", + " print(\"hatali giris yaptiniz.!\")\n", + " devam=input(\"Devam etmek isterseniz Y,Bitirmek icin N basin!\") \n", + " if devam==\"Y\":\n", + " continue\n", + " elif devam==\"N\" :\n", + " break\n", + " else:\n", + " print(\"Hesaplamamiz burada bitti.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4- The Least Common Multiple\n", + "As a user, I want to use a program which can calculate the least common multiple (L.C.M.) of four numbers. So that I can find the least common multiple (L.C.M.) of my inputs.\n", + "\n", + "Acceptance Criteria:\n", + "\n", + "Ask user to enter the four numbers.\n", + "Use try/except blocks to verify input entries and warn the user for Nan or non numerical inputs.\n", + "Calculate the least common multiple (L.C.M.) of four numbers\n", + "Use gcd function in module of math" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Lutfen 4 rakam bosluk birakarak yazin: 34 67 98 78\n", + "En Küçük Ortak Çarpanı 34,67,98,and 78 = ---4353258---\n" + ] + } + ], + "source": [ + "import math\n", + "ebob = math.gcd\n", + "\n", + "\n", + "numaralar = [] \n", + "ebob_list = [] \n", + "while True: \n", + " try: \n", + " numara = input(\"Lutfen 4 rakam bosluk birakarak yazin: \").strip(\" \").split()\n", + " for i in range(4):\n", + " numaralar.append(int(numara[i])) \n", + " break\n", + " except:\n", + " print(\"Lütfen yalnızca geçerli sayılar girin!\") \n", + "\n", + "ebob_list.append(ebob(numaralar[0], numaralar[1]))\n", + "ebob_list.append(ebob(numaralar[2], numaralar[3]))\n", + "\n", + "ekok_list = [] \n", + "n = 0\n", + "for i in range(2):\n", + " i += i\n", + " carpim = numaralar[i] * numaralar[i + 1]\n", + " ekok_list.append(int(carpim / ebob_list[n]))\n", + " n += 1\n", + "ebob_list2 = ebob(ekok_list[0], ekok_list[1])\n", + "ekok_result = ekok_list[0] * ekok_list[1]\n", + "result = ekok_result / ebob_list2 \n", + "print(\"En Küçük Ortak Çarpanı {},{},{},and {} = ---{}---\"\n", + " .format(numaralar[0], numaralar[1], numaralar[2], numaralar[3], int(result))) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}