<commit_before><commit_msg>Hacker rank examples<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 1:\n",
    "\n",
    "Given an integer, , perform the following conditional actions:\n",
    "\n",
    "If  is odd, print Weird\n",
    "If  is even and in the inclusive range of  to , print Not Weird\n",
    "If  is even and in the inclusive range of  to , print Weird\n",
    "If  is even and greater than , print Not Weird\n",
    "Input Format\n",
    "\n",
    "A single line containing a positive integer, .\n",
    "\n",
    "Constraints:\n",
    " 1<=n<=100\n",
    "\n",
    "Output Format\n",
    "\n",
    "Print Weird if the number is weird; otherwise, print Not Weird.\n",
    "\n",
    "Sample Input 0\n",
    "\n",
    "3\n",
    "Sample Output 0\n",
    "\n",
    "Weird\n",
    "Sample Input 1\n",
    "\n",
    "24\n",
    "Sample Output 1\n",
    "\n",
    "Not Weird\n",
    "Explanation\n",
    "\n",
    "Sample Case 0:  \n",
    " is odd and odd numbers are weird, so we print Weird.\n",
    "\n",
    "Sample Case 1:  \n",
    "n>20 and  n is even, so it isn't weird. Thus, we print Not Weird."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "42\n",
      "Not Weird\n"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    n = int(input())\n",
    "    if 1 <= n <= 100:\n",
    "        if n%2 ==0:\n",
    "            if n > 20 or 2<=n<=5:\n",
    "                print (\"Not Weird\")\n",
    "            else:\n",
    "                print (\"Weird\")\n",
    "        else:\n",
    "            print (\"Weird\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 2:\n",
    "\n",
    "Read two integers from STDIN and print three lines where:\n",
    "\n",
    "The first line contains the sum of the two numbers.\n",
    "The second line contains the difference of the two numbers (first - second).\n",
    "The third line contains the product of the two numbers.\n",
    "Input Format\n",
    "\n",
    "The first line contains the first integer, . The second line contains the second integer, .\n",
    "\n",
    "Constraints\n",
    "\n",
    "1<=a<=10e10 and 1<=b<=10e10\n",
    " \n",
    "Output Format\n",
    "\n",
    "Print the three lines as explained above.\n",
    "\n",
    "Sample Input\n",
    "\n",
    "3\n",
    "2 \n",
    "Sample Output\n",
    "\n",
    "5\n",
    "1\n",
    "6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "7\n",
      "12\n",
      "-2\n",
      "35\n"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    a = int(input())\n",
    "    b = int(input())\n",
    "    if 1<=a<=10e10 and 1<=b<=10e10:\n",
    "        print (a+b)\n",
    "        print (a-b)\n",
    "        print (a*b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 3:\n",
    "\n",
    "Read two integers and print two lines. The first line should contain integer division,  // . The second line should contain float division,  / .\n",
    "\n",
    "You don't need to perform any rounding or formatting operations.\n",
    "\n",
    "Input Format \n",
    "The first line contains the first integer, . The second line contains the second integer, .\n",
    "\n",
    "Output Format \n",
    "Print the two lines as described above.\n",
    "\n",
    "Sample Input\n",
    "\n",
    "4\n",
    "3\n",
    "sample Output\n",
    "\n",
    "1\n",
    "1.3333333333333333"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "9\n",
      "0\n",
      "0.8888888888888888\n"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    a = int(input())\n",
    "    b = int(input())\n",
    "    print (int(a//b))\n",
    "    print (float(a/b))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 4:\n",
    "\n",
    "Read an integer . For all non-negative integers , print . See the sample for details.\n",
    "\n",
    "Input Format\n",
    "\n",
    "The first and only line contains the integer, .\n",
    "\n",
    "Constraints\n",
    "\n",
    "1<=n<=20\n",
    "\n",
    "Output Format\n",
    "\n",
    "Print  lines, one corresponding to each .\n",
    "\n",
    "Sample Input\n",
    "\n",
    "5\n",
    "Sample Output\n",
    "\n",
    "0\n",
    "1\n",
    "4\n",
    "9\n",
    "16"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n",
      "0\n",
      "1\n",
      "4\n",
      "9\n",
      "16\n",
      "25\n",
      "36\n",
      "49\n",
      "64\n",
      "81\n",
      "100\n",
      "121\n",
      "144\n",
      "169\n",
      "196\n",
      "225\n",
      "256\n",
      "289\n",
      "324\n"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    n = int(input())\n",
    "    if 1<=n<=20:\n",
    "        for i in range(0,n):\n",
    "            print (i*i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 5:\n",
    "\n",
    "We add a Leap Day on February 29, almost every four years. The leap day is an extra, or intercalary day and we add it to the shortest month of the year, February. \n",
    "In the Gregorian calendar three criteria must be taken into account to identify leap years:\n",
    "\n",
    "The year can be evenly divided by 4, is a leap year, unless:\n",
    "The year can be evenly divided by 100, it is NOT a leap year, unless:\n",
    "The year is also evenly divisible by 400. Then it is a leap year.\n",
    "\n",
    "This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.Source\n",
    "\n",
    "Task \n",
    "You are given the year, and you have to write a function to check if the year is leap or not.\n",
    "\n",
    "Note that you have to complete the function and remaining code is given as template.\n",
    "\n",
    "Input Format\n",
    "\n",
    "Read y, the year that needs to be checked.\n",
    "\n",
    "Constraints\n",
    "\n",
    "1900 <= y <= 10e5\n",
    "\n",
    "Output Format\n",
    "\n",
    "Output is taken care of by the template. Your function must return a boolean value (True/False)\n",
    "\n",
    "Sample Input\n",
    "\n",
    "1990  \n",
    "Sample Output\n",
    "\n",
    "False  \n",
    "Explanation\n",
    "\n",
    "1990 is not a multiple of 4 hence it's not a leap year."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def is_leap(year):\n",
    "    if 1900<= year <= 10e5:\n",
    "        if year%4==0:\n",
    "            if year%100==0 and year%400==0:\n",
    "                leap = True\n",
    "            else:\n",
    "                if year%100==0:\n",
    "                    leap = False\n",
    "                else:\n",
    "                    leap = True\n",
    "        else:\n",
    "            leap = False    \n",
    "        return bool(leap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1970\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "year = int(input())\n",
    "print(is_leap(year))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Task 6:\n",
    "\n",
    "Read an integer N.\n",
    "\n",
    "Without using any string methods, try to print the following:\n",
    "\n",
    "123...N\n",
    "\n",
    "Note that \"\" represents the values in between.\n",
    "\n",
    "Input Format \n",
    "The first line contains an integer N.\n",
    "\n",
    "Output Format \n",
    "Output the answer as explained in the task.\n",
    "\n",
    "Sample Input\n",
    "\n",
    "3\n",
    "Sample Output\n",
    "\n",
    "123"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "12345"
     ]
    }
   ],
   "source": [
    "if __name__ == '__main__':\n",
    "    n = int(input())\n",
    "    for i in range(1, n+1):\n",
    "        print(i, end='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "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.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
{'fraction_non_alphanumeric': 0.206266318537859, 'fraction_numerical': 0.027816830688893353, 'mean_word_length': 1.793548387096774, 'pattern_counts': {'":': 114, '<': 25, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4929833', 'n_tokens_mistral': 3958, 'n_tokens_neox': 3731, 'n_words': 979}