diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d77270a..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/CovidRiskAssesment.ipynb b/CovidRiskAssesment.ipynb deleted file mode 100644 index 6063beb..0000000 --- a/CovidRiskAssesment.ipynb +++ /dev/null @@ -1,65 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "CovidRiskAssesment.ipynb", - "provenance": [], - "collapsed_sections": [], - "authorship_tag": "ABX9TyNGZluU8gZ+J8fuBs1Lypb4", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "Ip5D4qGfWPR0", - "outputId": "075d0855-1fb3-4bc2-d312-a4fc5f0db220" - }, - "source": [ - "age = input(\"Are you a cigarette addict older than 75 years old? \").upper()\n", - "chronic = input(\"Do you have a severe chronic disease? \").upper()\n", - "immune = input(\"Is your immune system too weak? \").upper()\n", - "\n", - "if age.startswith(\"Y\") or chronic.startswith(\"Y\") or immune.startswith(\"Y\") :\n", - " print(\"you are in risky group\")\n", - "else:\n", - " print(\"You are not in risky group\") \n" - ], - "execution_count": 1, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Are you a cigarette addict older than 75 years old? yes\n", - "Do you have a severe chronic disease? no\n", - "Is your immune system too weak? no\n", - "you are in risky group\n" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 78b9710..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# python -python self study diff --git a/armstrong_number.py b/armstrong_number.py deleted file mode 100644 index 042d51a..0000000 --- a/armstrong_number.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Task: - -Find out if a given number is an "Armstrong Number". - -An n-digit number that is the sum of the nth powers of its digits is called an n-Armstrong number. Examples : -371 = 33 + 73 + 13; -9474 = 94 + 44 + 74 + 44; -93084 = 95 + 35 + 05 + 85 + 45. - -Write a Python program that; -takes a positive integer number from the user, -checks the entered number if it is Armstrong, -consider the negative, float and any entries other than numeric values then display a warning message to the user. -""" - -num = input("Enter your number: ") - -if num.isdigit() and int(num) > 0 : - length = len(num) - sum = 0 - for order in num: - order = int(order) - sum += order ** length - if int(num) == sum: - print("{} is an armstrong number".format(num)) - else: - print("{} is not an armstrong number".format(num)) - -else: - print("It is an invalid entry. Don't use non-numeric, float, or negative values!") diff --git a/armstrong_numbers_between_intervals.py b/armstrong_numbers_between_intervals.py deleted file mode 100644 index b5e9f57..0000000 --- a/armstrong_numbers_between_intervals.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -write a program to find all the Armstrong numbers present in between two intervals in Python. -For example, Armstrong numbers between 100 and 2000. -Expected output: -153 -370 -371 -407 -1634 - -""" - - -lower_num, higher_num = list(map(int, input("").split())) -for i in range(lower_num, higher_num+1) : - if sum([int(j) ** len(str(i)) for j in str(i)]) == i : - print(i) \ No newline at end of file diff --git a/atomic_numbers.py b/atomic_numbers.py deleted file mode 100644 index 94e9aa0..0000000 --- a/atomic_numbers.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -You are a khmmadkhm scientist and you decided to play with electron distribution among atom's shells. You know that basic idea of electron distribution is that electrons should fill a shell untill it's holding the maximum number of electrons. -Rules: -Maximum number of electrons in a shell is distributed with a rule of 2n^2 (n being position of a shell). -For example, maximum number of electrons in 3rd shield is 2*3^2 = 18. -Electrons should fill the lowest level shell first. -If the electrons have completely filled the lowest level shell, the other unoccupied electrons will fill the higher level shell and so on. -Ex.: atomicNumber(1); should return [1] - atomicNumber(10); should return [2, 8] - atomicNumber(11); should return [2, 8, 1] - atomicNumber(47); should return [2, 8, 18, 19] -""" - - -def atomicNumber(num) : - arry, n = [] , 1 - n_num = num - if 0 <= num <= 2 : - return [num] - else : - while num >= 0 : - num = num - (2 * n ** 2) - arry += [2 * n ** 2] - n += 1 - if num < (2 * n ** 2) : - arry.pop() - arry += [n_num - sum(arry)] - return arry \ No newline at end of file diff --git a/comfortable_words.py b/comfortable_words.py deleted file mode 100644 index 9899b80..0000000 --- a/comfortable_words.py +++ /dev/null @@ -1,18 +0,0 @@ -''' -Task : Find out if the given word is "comfortable words" in relation to the ten-finger keyboard use. - -A comfortable word is a word which you can type always alternating the hand you type with (assuming you type using a Q-keyboard and use of the ten-fingers standard). - -The word will always be a string consisting of only letters from a to z. - -Write a program which returns True if it's a comfortable word or False otherwise. -''' - -left_h = "q, w, e, r, t, a, s, d, f, g, z, x, c, v, b" -right_h = "y, u, i, o, p, h, j, k, l, n, m" -word = set(input("").lower()) - -if word - set(left_h) == set() or word - set(right_h) == set() : - print(False) -else: - print(True) \ No newline at end of file diff --git a/data_type.py b/data_type.py deleted file mode 100644 index 3d51aa8..0000000 --- a/data_type.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -Given a function that accepts unlimited arguments, check and count how many data types are in those arguments. Finally return the total in a list. -List order is: -[int, str, bool, list, tuple, dictionary] -Examples -[1, 45, "Hi", False] ➞ [2, 1, 1, 0, 0, 0] -[[10, 20], ("t", "Ok"), 2, 3, 1] ➞ [3, 0, 0, 1, 1, 0] -["Hello", "Bye", True, True, False, {"1": "One", "2": "Two"}, [1, 3], {"Brayan": 18}, 25, 23] ➞ [2, 2, 3, 1, 0, 2] -[4, 21, ("ES", "EN"), ("a", "b"), False, [1, 2, 3], [4, 5, 6] ]➞ [2, 0, 1, 2, 2, 0] -""" - -data = ["a", "b", True, (False,1), {1:"2"}, [1,2], {"2":"two"}, {2,"3"}, "c", 23, 0] -tip = ["int", "str", "bool", "list", "tuple", "dict"] -total = {}.fromkeys(tip, 0) -for i in range(len(data)) : - if type(data[i]) == str : - total["str"] += 1 - elif type(data[i]) == bool : - total["bool"] += 1 - elif type(data[i]) == tuple : - total["tuple"] += 1 - elif type(data[i]) == list : - total["list"] += 1 - elif type(data[i]) == dict : - total["dict"] += 1 - elif type(data[i]) == int : - total["int"] += 1 -print(list( total.values())) \ No newline at end of file diff --git a/deepest_sublist.py b/deepest_sublist.py deleted file mode 100644 index 043dc7a..0000000 --- a/deepest_sublist.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -You are given a list which may contain sublists. Your task is to find the depth of the deepest sublist. -[a] = 1 depth -[[a]] = 2 depth -[[[a]]] = 3 depth, etc -Examples -deepest([1, [2, 3], 4, [5, 6]]) ➞ 2 -deepest([[[[[[[[[[1]]]]]]]]]]) ➞ 10 -deepest([1, 4, [1, 4, [1, 4, [1, 4, [5]]]]]) ➞ 5 -""" - -def deepest(arry) : - s = str(arry) - count = [i for i in s if i == "["] - return len(count) -deepest([1, 4, [1, 4, [1, 4, [1, 4, [5]]]]]) \ No newline at end of file diff --git a/fibonacci.py b/fibonacci.py deleted file mode 100644 index 6c47aa3..0000000 --- a/fibonacci.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Task : Create a list consisting of Fibonacci numbers from 1 to 55 using control flow statements. - -The desired output is like : - -fibonacci → [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] -""" - - - -x,y = 1,1 -z = 0 -liste = [x,y] - -while z < 55: - - - z = x + y - x = y - y = z - liste.append(z) - -print(liste) - diff --git a/greatest_common_divisor.py b/greatest_common_divisor.py deleted file mode 100644 index 2a81d01..0000000 --- a/greatest_common_divisor.py +++ /dev/null @@ -1,15 +0,0 @@ -''' -Write a Python program to compute the greatest common divisor (GCD) of two positive integers -''' - -num1 = int(input("please enter a number : ")) -num2 = int(input("please enter a number : ")) -if num1 > num2 : - bolen = num2 -else: - bolen = num1 -for i in range(1,bolen+1): - if num1 % i == 0 and num2 % i == 0 : - total = i - -print(total) \ No newline at end of file diff --git a/palindrome.py b/palindrome.py deleted file mode 100644 index 5c2ff9c..0000000 --- a/palindrome.py +++ /dev/null @@ -1,20 +0,0 @@ -''' -Write a program to check if a given string is a Palindrome. -A palindrome reads same from front and back e.g.- aba, ccaacc, mom, etc. - -INPUT: aba - -OUTPUT: True -''' - -sentence = input("please enter the sentence : ") -new_st = "" - -for i in sentence : - if i.isalnum(): - new_st += i - -if new_st[::-1].lower() == new_st[::].lower() : - print("{} is a palindrome.".format(sentence)) -else: - print("{} is not a palindrome.".format(sentence)) \ No newline at end of file diff --git a/pascal.py b/pascal.py deleted file mode 100644 index 75421fd..0000000 --- a/pascal.py +++ /dev/null @@ -1,18 +0,0 @@ -''' -To form a pascal triangle in Python, there is a stepwise in the software. -Firstly, an input number is taken from the user to define the number of rows. -Secondly, an empty list is defined, which is used to store values. -Then, a for loop is used to iterate from 0 to n-1 that append the sub-lists to the initial list. -''' - -pascal = [[1]] -num = int(input("Number of iterations: ")) -print(pascal[0]) # the very first row -for i in range(1,num+1): - pascal.append([1]) # start off with 1 - for j in range(len(pascal[i-1])-1): - # the number of times we need to run this loop is (# of elements in the row above)-1 - pascal[i].append(pascal[i-1][j]+pascal[i-1][j+1]) - # add two adjacent numbers of the row above together - pascal[i].append(1) # and cap it with 1 - print(pascal[i]) \ No newline at end of file diff --git a/password-reminder.py b/password-reminder.py deleted file mode 100644 index b08c118..0000000 --- a/password-reminder.py +++ /dev/null @@ -1,19 +0,0 @@ - -""" -Task: -Let's say; you left a message in the past that prints a password you need. To see the password you wrote, you need to enter your name and the program should recognize you. Write a program that -Takes the first name from the user and compares it to yours, -Then if the name the user entered is the same as yours, print out such as : "Hello, Joseph! The password is : W@12", -If the name the user entered is not the same as yours, print out such as : "Hello, Amina! See you later." -""" - -#Solution: - -password = "qw12" -name = "berin" -user_name = input("please enter your first name: ") - -if user_name == name: - print("Hello, {}! The password is : {}".format(name,password)) -else: - print("Hello {}! See you later".format(user_name)) diff --git a/perfectNumbers.py b/perfectNumbers.py deleted file mode 100644 index a743eca..0000000 --- a/perfectNumbers.py +++ /dev/null @@ -1,11 +0,0 @@ -''' -Try to find out if a number you get from the user is perfect. -A number is called a "perfect number" if the sum of its divisors is equal to itself. For example, 6 is a perfect number. (1 + 2 + 3 = 6) -''' - -num = int(input("")) -total = sum([i for i in range(1,num) if num % i == 0]) -if total == num : - print("{} is a perfect number.".format(num)) -else: - print("{} is not a perfect number.".format(num)) \ No newline at end of file diff --git a/phonebook.py b/phonebook.py deleted file mode 100644 index 16547e0..0000000 --- a/phonebook.py +++ /dev/null @@ -1,42 +0,0 @@ - - - -def print_menu(): - print('1. Find phone number') - print('2. Insert a phone number') - print('3. Delete a person from the phonebook') - print('4. Terminate') - print() - -numbers = {} -menu_choice = 0 -print_menu() -while menu_choice != 4: - menu_choice = int(input("Type in a number (1-4): ")) - - if menu_choice == 2: - print("Insert Name of the person") - name = input("Name: ") - print("Insert phone number of the person") - phone = input("Number: ") - numbers[name] = phone - print("Phone number of {} is inserted into the phonebook".format(name)) - elif menu_choice == 3: - print("Whom to delete from phonebook :") - name = input("") - if name in numbers: - del numbers[name] - print("{} is deleted from the phonebook".format(name)) - else: - print(name, "'s phone number couldn't find") - elif menu_choice == 1: - print("Find the phone number of : ") - name = input("") - if name in numbers: - print("The number is", numbers[name]) - else: - print(name, "'s phone number couldn't find") - elif menu_choice != 4: - print_menu() -if menu_choice == 4: - print("Exiting Phonebook") \ No newline at end of file diff --git a/prime_numbers.py b/prime_numbers.py index 2015fd9..591f6b8 100644 --- a/prime_numbers.py +++ b/prime_numbers.py @@ -1,20 +1,22 @@ -""" Task : Write a program that takes a number from the user and prints the result to check if it is a prime number. +""" +Task : Write a program that takes a number from the user and prints the result to check if it is a prime number. The examples of the desired output are as follows : input → 19 ⇉ output : 19 is a prime number -input → 10 ⇉ output : 10 is not a prime number """ - +input → 10 ⇉ output : 10 is not a prime number +""" num = int(input("please enter a number: ")) if num > 1: - for i in range (2,num): - if (num % i) == 0: - print("{} is not a prime number.".format(num)) - break - else: - print("{} is a prime number.".format(num)) + + for i in range (2,num): + if (num % i) == 0: + print("{} is not a prime number.".format(num)) + break + else: + print("{} is a prime number.".format(num)) else: - print("{} is neither prime nor opposite.".format(num)) + print("{} is neither prime nor opposite.".format(num)) \ No newline at end of file diff --git a/pythagorean_triangle.py b/pythagorean_triangle.py deleted file mode 100644 index dea3441..0000000 --- a/pythagorean_triangle.py +++ /dev/null @@ -1,10 +0,0 @@ -''' -Write a program that prints the numbers from 1 to 100 that form a pythagorean triangle. -For example:3 4 5 -''' - -for x in range(1,100) : - for y in range(x,100) : - for z in range(y,100) : - if x ** 2 + y **2 == z ** 2 : - print(x,y,z) \ No newline at end of file