<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Control flows"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### if statements"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Non-negative\n"
     ]
    }
   ],
   "source": [
    "x = 10\n",
    "\n",
    "if x < 0:\n",
    "    print 'Negative'\n",
    "else:\n",
    "    print 'Non-negative'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## for statements\n",
    "\n",
    "* the **for** statement in python differs with the other languages.\n",
    "\n",
    "* No loop over an arithmetic progression of numbers. e.g: cannot write <pre>for(int i = 0; i < 10; i++)</pre>\n",
    "\n",
    "* only loop over the items of any sequence"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I own a cat\n",
      "I own a dog\n",
      "I own a pig\n"
     ]
    }<commit_msg>update control flows<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Control flows"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### if statements\n",
    "\n",
    "* Look at the sample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Negative changed to zero\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "x = -5\n",
    "\n",
    "if x < 0:\n",
    "    x = 0\n",
    "    print 'Negative changed to zero'\n",
    "elif x == 0:\n",
    "    print 'Zero'\n",
    "elif x == 1:\n",
    "    print 'Single'\n",
    "else:\n",
    "    print 'More'\n",
    "    \n",
    "print x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* the body of the if is indented\n",
    "    + indentation is python 's way to grouping statement (code block). C using brackets for grouping.\n",
    "    + each line within a code block must bee indented by the same about.\n",
    "    + you should use only tab to indent or spaces to indent\n",
    "* There can be zero or more elif parts, and the else part is optional"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## for statements\n",
    "\n",
    "* the **for** statement in python differs with the other languages.\n",
    "\n",
    "* No loop over an arithmetic progression of numbers. e.g: cannot write <pre>for(int i = 0; i < 10; i++)</pre>\n",
    "\n",
    "* only loop over the items of any sequence"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I own a cat\n",
      "I own a dog\n",
      "I own a pig\n"
     ]
    }
{'fraction_non_alphanumeric': 0.1990034257240735, 'fraction_numerical': 0.006228589224540642, 'mean_word_length': 1.974074074074074, 'pattern_counts': {'":': 57, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '5864331', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1176, 'n_words': 313}