├── .DS_Store ├── PiscinePython42 ├── .DS_Store ├── Day00 │ ├── en.subject.pdf │ ├── ex00 │ │ ├── answers.txt │ │ └── requirements.txt │ ├── ex01 │ │ ├── exec.py │ │ └── my_stdout.txt │ ├── ex02 │ │ └── whois.py │ ├── ex03 │ │ ├── __pycache__ │ │ │ └── count.cpython-311.pyc │ │ └── count.py │ ├── ex04 │ │ └── operation.py │ ├── ex05 │ │ ├── kata00.py │ │ ├── kata01.py │ │ ├── kata02.py │ │ ├── kata03.py │ │ └── kata04.py │ ├── ex06 │ │ └── recipe.py │ ├── ex07 │ │ └── filterwords.py │ ├── ex08 │ │ └── sos.py │ ├── ex09 │ │ └── guess.py │ └── ex10 │ │ └── loading.py ├── Day01 │ └── en.subject (1).pdf ├── Day02 │ └── en.subject.pdf ├── Day03 │ └── en.subject (1).pdf └── Day04 │ └── en.subject.pdf ├── Projects ├── SnakeGame │ └── main.py └── TransletApp │ ├── textToSpeech.py │ └── translet_app.py ├── README.md ├── conda.sh └── course ├── ForLoop.py ├── Functions.py ├── GetingInput.py ├── IfStatement.py ├── Lists.py ├── Set.py ├── Stringd.py ├── TryExcept.py ├── Tuples.py ├── classAndObject ├── Doctor.py ├── Employee.py ├── __pycache__ │ └── Doctor.cpython-39.pyc ├── classAndObject.py └── inheritance.py ├── conda.txt ├── fiveConcept.py ├── readingFile.py └── writingFile.py /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/.DS_Store -------------------------------------------------------------------------------- /PiscinePython42/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/.DS_Store -------------------------------------------------------------------------------- /PiscinePython42/Day00/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day00/en.subject.pdf -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex00/answers.txt: -------------------------------------------------------------------------------- 1 | #Output a list of installed packages and their versions 2 | o output a list of installed packages and their versions in conda, 3 | you can use the following command in your terminal or Anaconda Prompt: 4 | 5 | | 6 | |____ in conda : @> conda list 7 | 8 | For Python packages installed with pip, you can use 9 | the following command in your terminal or command prompt: 10 | 11 | | 12 | |____ or : @> pip list 13 | | 14 | |____ For packages installed with the apt package manager on Linux systems, 15 | you can use the following command in your terminal : @> dpkg --list 16 | 17 | # Show the package metadata of numpy 18 | 1. To show the package metadata of NumPy in Python, 19 | you can use the pip show command followed by the package name. Here's how to do it: 20 | 21 | | 22 | |____ @> pip show numpy 23 | 24 | 2. To show the package metadata of NumPy using conda, 25 | you can use the following command in your terminal or Anaconda Prompt: 26 | | 27 | |_____ using conda : @> conda info numpy 28 | 29 | # Remove the package numpy 30 | 1. o remove the NumPy package from your Python environment using 31 | pip, you can use the following command in your terminal or command prompt 32 | 33 | | 34 | |____ @> pip uninstall numpy 35 | 36 | 2. If you are using conda, you can use the following command in your terminal or Anaconda Prompt 37 | 38 | | 39 | |____ @> conda remove numpy 40 | 41 | # (Re)install the package numpy 42 | 43 | To (re)install the NumPy package in your Python environment using pip, 44 | you can use the following command in your terminal or command prompt: 45 | 46 | | 47 | |____ @> pip install numpy 48 | 49 | If you want to install a specific version of NumPy, you can use the following pip command: 50 | | 51 | |___ @> pip install numpy== 52 | 53 | If you are using conda, you can use the following command in your terminal or Anaconda Prompt: 54 | 55 | | 56 | |____ @> conda install numpy 57 | 58 | If you are using conda, you can use the following command to install a specific version of NumPy: 59 | 60 | | 61 | |____ @> conda install numpy= 62 | 63 | # Freeze your python packages and their versions in a requirements.txt file you 64 | have to turn-in. 65 | 66 | 67 | To freeze your Python packages and their versions in a requirements.txt file, 68 | you can use the pip freeze command. Here are the steps: 69 | | 70 | |____ @> pip freeze > requirements.txt -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex00/requirements.txt: -------------------------------------------------------------------------------- 1 | #The requirements.txt file will ensure that anyone who wants to run your code 2 | #can do so using the same packages and 3 | #versions that you used during development. 4 | 5 | anyio @ file:///opt/concourse/worker/volumes/live/2d0c1872-84e3-41ed-52ee-4acda8e34dde/volume/anyio_1644481707760/work/dist 6 | appnope @ file:///opt/concourse/worker/volumes/live/4f734db2-9ca8-4d8b-5b29-6ca15b4b4772/volume/appnope_1606859466979/work 7 | argon2-cffi @ file:///opt/conda/conda-bld/argon2-cffi_1645000214183/work 8 | argon2-cffi-bindings @ file:///opt/concourse/worker/volumes/live/c6f9b05d-dc80-4dbc-7473-70bfcb66883c/volume/argon2-cffi-bindings_1644569703264/work 9 | attrs @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_33k1uces4n/croot/attrs_1668696162258/work 10 | Babel @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_59c7q3smap/croot/babel_1671781946809/work 11 | backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work 12 | beautifulsoup4 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_croot-cdiouih5/beautifulsoup4_1650462164803/work 13 | bleach @ file:///opt/conda/conda-bld/bleach_1641577558959/work 14 | Bottleneck @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_29949159-f86f-474b-bc1f-aaa1e0e222b4ofusifik/croots/recipe/bottleneck_1657175564045/work 15 | brotlipy==0.7.0 16 | certifi @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_477u68wvzm/croot/certifi_1671487773341/work/certifi 17 | cffi @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_1b0qzba5nr/croot/cffi_1670423213150/work 18 | chardet @ file:///opt/concourse/worker/volumes/live/9efbf151-b45b-463d-6340-a5c399bf00b7/volume/chardet_1607706825988/work 19 | charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work 20 | conda==23.1.0 21 | conda-build==3.23.3 22 | conda-package-handling @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_f5r7ncch6s/croot/conda-package-handling_1672865026931/work 23 | conda_package_streaming @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_619dxy_gif/croot/conda-package-streaming_1670508154637/work 24 | cryptography @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_19cvzxmeb9/croot/cryptography_1677533085498/work 25 | debugpy @ file:///opt/concourse/worker/volumes/live/32b11d06-4d64-4ec8-497a-cf4fc97343d2/volume/debugpy_1637091821874/work 26 | decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work 27 | defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work 28 | entrypoints @ file:///opt/concourse/worker/volumes/live/194c0a28-55ce-4e83-6a87-0d9f2e06ab2c/volume/entrypoints_1649926487944/work 29 | fastjsonschema @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_b5c1gee32t/croots/recipe/python-fastjsonschema_1661368622875/work 30 | filelock @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_f29yrmlw9_/croot/filelock_1672387130651/work 31 | flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core 32 | glob2 @ file:///home/linux1/recipes/ci/glob2_1610991677669/work 33 | idna @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_00jf0h4zbt/croot/idna_1666125573348/work 34 | importlib-metadata @ file:///opt/concourse/worker/volumes/live/4e1a3384-472f-4bcb-7776-cb0076aaea40/volume/importlib-metadata_1648562431336/work 35 | importlib-resources @ file:///tmp/build/80754af9/importlib_resources_1625135880749/work 36 | ipykernel @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_05yte6zd0k/croots/recipe/ipykernel_1662361808878/work 37 | ipython @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_b9echyik_d/croots/recipe/ipython_1659529861316/work 38 | ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work 39 | ipywidgets @ file:///tmp/build/80754af9/ipywidgets_1634143127070/work 40 | jedi @ file:///opt/concourse/worker/volumes/live/c9d2fa99-8bc1-4572-41e7-6beba6391441/volume/jedi_1644315238822/work 41 | Jinja2 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_6adj7x0ejx/croot/jinja2_1666908137966/work 42 | json5 @ file:///tmp/build/80754af9/json5_1624432770122/work 43 | jsonschema @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_21cqeq1xnk/croot/jsonschema_1676558686956/work 44 | jupyter @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_e35x81mm4c/croots/recipe/jupyter_1659349054503/work 45 | jupyter-console @ file:///opt/conda/conda-bld/jupyter_console_1647002188872/work 46 | jupyter-server @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_031akrjssy/croot/jupyter_server_1671707631142/work 47 | jupyter_client @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_dfnfn9c33q/croot/jupyter_client_1676329090115/work 48 | jupyter_core @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_f5x3brmrnq/croots/recipe/jupyter_core_1664917315750/work 49 | jupyterlab @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_a52a346vyc/croot/jupyterlab_1675354129045/work 50 | jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work 51 | jupyterlab-widgets @ file:///tmp/build/80754af9/jupyterlab_widgets_1609884341231/work 52 | jupyterlab_server @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_447yg3joq7/croot/jupyterlab_server_1677149708049/work 53 | libarchive-c @ file:///tmp/build/80754af9/python-libarchive-c_1617780486945/work 54 | lxml @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_1902c961-4bd2-4871-a3c5-70b7317a6521kpj7nz2o/croots/recipe/lxml_1657545138937/work 55 | MarkupSafe @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_d4a9444f-bd4c-4043-b47d-cede33979b0fve7bm42r/croots/recipe/markupsafe_1654597878200/work 56 | matplotlib-inline @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_9ddl71oqte/croots/recipe/matplotlib-inline_1662014471815/work 57 | mistune==0.8.4 58 | mkl-fft==1.3.1 59 | mkl-random @ file:///opt/concourse/worker/volumes/live/133f1d0b-8fd8-4fa0-679e-7214401cbd75/volume/mkl_random_1626186083386/work 60 | mkl-service==2.4.0 61 | nbclassic @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_7c3czojxw1/croot/nbclassic_1676902906096/work 62 | nbclient @ file:///opt/concourse/worker/volumes/live/2b77047f-e15a-4d19-54ac-7d87d20b74de/volume/nbclient_1650308375803/work 63 | nbconvert @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_8fyzuglni_/croot/nbconvert_1668450649428/work 64 | nbformat @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_2daun1fill/croot/nbformat_1670352339504/work 65 | nest-asyncio @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_64pfm74mxq/croot/nest-asyncio_1672387129786/work 66 | notebook @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_0cdyriuhi_/croot/notebook_1668179888986/work 67 | notebook_shim @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_e9s6zsmlb7/croot/notebook-shim_1668160584892/work 68 | numexpr @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_cef3ah6r8w/croot/numexpr_1668713880672/work 69 | numpy @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_10c245a1-1c81-453c-8b70-3e944787a8d9mo1xhesu/croots/recipe/numpy_and_numpy_base_1653915529188/work 70 | packaging @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_bet5qdixgt/croot/packaging_1671697440883/work 71 | pandas==1.3.5 72 | pandocfilters @ file:///opt/conda/conda-bld/pandocfilters_1643405455980/work 73 | parso @ file:///opt/conda/conda-bld/parso_1641458642106/work 74 | pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work 75 | pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work 76 | pkginfo @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_9aeuxsywo9/croot/pkginfo_1666725052115/work 77 | pkgutil_resolve_name @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_c9l5hym8w0/croots/recipe/pkgutil-resolve-name_1661463329338/work 78 | pluggy @ file:///opt/concourse/worker/volumes/live/b4f0e253-7a56-4c04-781c-49509af26e8e/volume/pluggy_1648042585672/work 79 | ply==3.11 80 | prometheus-client @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_19kjbndib7/croots/recipe/prometheus_client_1659455105394/work 81 | prompt-toolkit @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_82emz7mook/croot/prompt-toolkit_1672387300396/work 82 | psutil @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_c9b604bf-685f-47f6-8304-238e4e70557e1o7mmsot/croots/recipe/psutil_1656431274701/work 83 | ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl 84 | pycodestyle @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_a7riaf725h/croot/pycodestyle_1674267226642/work 85 | pycosat @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_ebsmghz9nu/croot/pycosat_1666805511853/work 86 | pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work 87 | Pygments @ file:///opt/conda/conda-bld/pygments_1644249106324/work 88 | pyOpenSSL @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_6dweji2whw/croot/pyopenssl_1677607689781/work 89 | PyQt5-sip==12.11.0 90 | pyrsistent @ file:///opt/concourse/worker/volumes/live/24b7a9ab-37d8-463c-575f-69184f9cfbc8/volume/pyrsistent_1636111022304/work 91 | PySocks @ file:///opt/concourse/worker/volumes/live/ef943889-94fc-4539-798d-461c60b77804/volume/pysocks_1605305801690/work 92 | python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work 93 | pytz @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_ddzpsmm2_f/croot/pytz_1671697430473/work 94 | PyYAML @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_79xo15pf1i/croot/pyyaml_1670514753622/work 95 | pyzmq @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_15f7a459-ad98-422b-b8da-cbf1f626e2115nt0ocwy/croots/recipe/pyzmq_1657724193704/work 96 | qtconsole @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_acf6cfsn_t/croot/qtconsole_1674008438217/work 97 | QtPy @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_4e5ppuhz0f/croots/recipe/qtpy_1662014536017/work 98 | requests @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_516b78ce-034d-4395-b9b5-1d78c2847384qtnol99l/croots/recipe/requests_1657734628886/work 99 | ruamel.yaml @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_7de1zqcaou/croot/ruamel.yaml_1666304553877/work 100 | ruamel.yaml.clib @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_c7s0zxy4t2/croot/ruamel.yaml.clib_1666302244557/work 101 | Send2Trash @ file:///tmp/build/80754af9/send2trash_1632406701022/work 102 | sip @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_88z1zrsfrf/croots/recipe/sip_1659012373083/work 103 | six @ file:///tmp/build/80754af9/six_1644875935023/work 104 | sniffio @ file:///opt/concourse/worker/volumes/live/838fa2d9-a35b-4591-50ce-1f1a39baa1df/volume/sniffio_1614030463440/work 105 | soupsieve @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_14fb2zs6e3/croot/soupsieve_1666296397588/work 106 | terminado @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_18_p3gbeio/croot/terminado_1671751835656/work 107 | tinycss2 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_56dshjmms6/croot/tinycss2_1668168824483/work 108 | toml @ file:///tmp/build/80754af9/toml_1616166611790/work 109 | tomli @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_90762ba4-f339-47e8-bd29-416854a59b233d27hku_/croots/recipe/tomli_1657175507767/work 110 | toolz @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_a7gkswah88/croot/toolz_1667464082910/work 111 | tornado @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_1fimz6o0gc/croots/recipe/tornado_1662061695695/work 112 | tqdm @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_2adqcbsqqd/croots/recipe/tqdm_1664392689227/work 113 | traitlets @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_0dtilxc0bw/croot/traitlets_1671143889152/work 114 | typing_extensions @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_4b7xacf029/croot/typing_extensions_1669923792404/work 115 | urllib3 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_4cyi6_u2vj/croot/urllib3_1673575523861/work 116 | wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work 117 | webencodings==0.5.1 118 | websocket-client @ file:///opt/concourse/worker/volumes/live/27763808-0b51-45c4-7a46-77805b7949ef/volume/websocket-client_1614804248608/work 119 | widgetsnbextension @ file:///opt/concourse/worker/volumes/live/d0e5739b-8078-4a19-69bb-be63aeed72df/volume/widgetsnbextension_1645009381873/work 120 | zipp @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_b71z79bye2/croot/zipp_1672387125902/work 121 | zstandard @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_40ayfv1xn6/croot/zstandard_1677014126754/work 122 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex01/exec.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | #print("Python version", sys.version) 4 | 5 | # stdin, stdout, stderr (input, output and error channels) control 6 | 7 | #sys.stdout.write('hello\n') 8 | 9 | # Control channel 10 | 11 | #fd = open('my_stdout.txt', 'w') 12 | 13 | #sys.stdout = fd 14 | 15 | #print('hellllllllloooooooo') 16 | #sys.stdout.close() 17 | #sys.stdout = sys.__stdout__ 18 | #print("hello again") 19 | 20 | # Max int size 21 | 22 | # Commande line arguments 23 | 24 | #print("Sys argv: ", sys.argv) 25 | #for path in sys.path: 26 | # print("Path: ", path) 27 | 28 | #print("argc: ", len(sys.argv)) 29 | def my_reverse(str): 30 | return str[::-1] 31 | 32 | lenght = len(sys.argv) 33 | 34 | if lenght == 1: 35 | sys.exit() 36 | 37 | result = "" 38 | i = lenght - 1 39 | while i > 0: 40 | result += my_reverse(sys.argv[i]).swapcase() 41 | if i != 1: 42 | result += " " 43 | i -= 1 44 | print(result) 45 | 46 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex01/my_stdout.txt: -------------------------------------------------------------------------------- 1 | hellllllllloooooooo 2 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex02/whois.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | lenght = len(sys.argv) 4 | 5 | if lenght > 2: 6 | print("AssertionError: more than one argument are provided") 7 | elif lenght == 2 and not sys.argv[1].isnumeric(): 8 | print("AssertionError: argument is not an integer") 9 | else: 10 | if int(sys.argv[1]) == 0: 11 | print("I'm Zero") 12 | elif int(sys.argv[1]) % 2 == 0: 13 | print("I'm Even") 14 | else: 15 | print("I'M Odd") 16 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex03/__pycache__/count.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day00/ex03/__pycache__/count.cpython-311.pyc -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex03/count.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def text_analyzer(string=None): 4 | ''' 5 | This function counts the number 6 | of upper characters, lower characters, 7 | punctuation and spaces in a given text. 8 | ''' 9 | if string is None or string == '': 10 | string = input("What is the text to analyze? \n") 11 | upper, lower, punctuation, space = 0, 0, 0, 0 12 | if type(string) != str: 13 | print("AssertionError: argument is not a string") 14 | exit() 15 | print("The text contains " + str(len(string)) + " character(s):") 16 | for i in range(len(string)): 17 | if string[i].isupper(): 18 | upper += 1 19 | elif string[i].islower(): 20 | lower += 1 21 | elif string[i] == ' ': 22 | space += 1 23 | elif not string[i].isdigit(): 24 | punctuation += 1 25 | print("- " + str(upper) + " upper letter(s)") 26 | print("- " + str(lower) + " lower letter(s)") 27 | print("- " + str(punctuation) + " punctuation mark(s)") 28 | print("- " + str(space) + " space(s)") 29 | 30 | lenght = len(sys.argv) 31 | 32 | if lenght > 2: 33 | print("invalid argument!!\n") 34 | elif lenght == 2: 35 | text_analyzer(sys.argv[1]) 36 | 37 | #for test 38 | #$> python3 39 | #>>> from count import text_analyzer 40 | #>>> text_analyzer("Python 2.0, released 2000, introduced 41 | #features like List comprehensions and a garbage collection 42 | #system capable of collecting reference cycles.") 43 | #The text contains 143 character(s): 44 | #- 2 upper letter(s) 45 | #- 113 lower letter(s) 46 | #- 4 punctuatio 47 | #>>> print(text_analyzer.__doc__) 48 | #This function counts the number of upper characters, lower characters, 49 | #punctuation and spaces in a given text. -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex04/operation.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | lenght = len(sys.argv) 4 | 5 | if lenght > 3: 6 | print("AssertionError: too many arguments!!") 7 | elif lenght < 3: 8 | print("Usage: python operations.py \n\ 9 | Example:\n\ 10 | python operations.py 10 3") 11 | else: 12 | if sys.argv[1].isdigit() and sys.argv[2].isdigit(): 13 | try: 14 | print("sum: " + str(int(sys.argv[1]) + int(sys.argv[2]))) 15 | print("Difference: " + str(int(sys.argv[1]) - int(sys.argv[2]))) 16 | print("Product: " + str(int(sys.argv[1]) * int(sys.argv[2]))) 17 | print("Quotient: " + str(int(sys.argv[1]) / int(sys.argv[2]))) 18 | print("Remainder: " + str(int(sys.argv[1]) % int(sys.argv[2]))) 19 | except ZeroDivisionError: 20 | print("Quotient: ERROR (division by zero)") 21 | print("Remainder: ERROR (module by zero)") 22 | except: 23 | print("invalid operation!") 24 | else: 25 | print("AssertionError: only integers") 26 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex05/kata00.py: -------------------------------------------------------------------------------- 1 | kata = (19, 42, 21) 2 | 3 | print(f"The {len(kata)} numbers are: {', '.join(str(num) for num in kata)}") 4 | print(f"The {len(kata)} numbers are: {kata[0]}, {kata[1]}. {kata[2]}") -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex05/kata01.py: -------------------------------------------------------------------------------- 1 | kata = { 2 | 'Python': 'Guido van Rossum', 3 | 'Ruby': 'Yukihiro Matsumoto', 4 | 'PHP': 'Rasmus Lerdorf', 5 | } 6 | 7 | #for key in kata.keys(): 8 | # print(key, "was created by", kata[key]) 9 | 10 | for language, creator in kata.items(): 11 | print(f"{language} was created by {creator}") -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex05/kata02.py: -------------------------------------------------------------------------------- 1 | kata = (2019, 9, 25, 3, 30) 2 | 3 | print(f'{kata[1]:02d}/{kata[2]:02d}/{kata[0]:4d} \ 4 | {kata[3]:02d}:{kata[4]:02d}') 5 | -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex05/kata03.py: -------------------------------------------------------------------------------- 1 | kata = "The right format" 2 | 3 | lengh = len(kata) 4 | 5 | print("-"*(41 - lengh) + kata) -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex05/kata04.py: -------------------------------------------------------------------------------- 1 | kata = (0, 4, 132.42222, 10000, 12345.67) 2 | 3 | print(f"module_{kata[0]:02d}, ex_{kata[1]:02d} : {kata[2]:.2f}, {kata[3]:.2e}, {kata[4]:.2e}") -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex06/recipe.py: -------------------------------------------------------------------------------- 1 | # Part 1: Nested Dictionaries 2 | 3 | cookbook = { 4 | 'Sandwish' : { 5 | 'ingredients' : ["ham", "bread", "cheese", "tomatoes"], 6 | 'meal' : "lunch", 7 | 'prep_time' : 10 8 | }, 9 | 'Cake' : { 10 | 'ingredients' : ["flour", "sugar", "eggs"], 11 | 'meal' : "dessert", 12 | 'prep_time' : 60 13 | }, 14 | 'Salade' : { 15 | 'ingredients' : ["avocado", "arugula", "tomatoes", "spinach"], 16 | 'meal' : "lunch", 17 | 'prep_time' : 15 18 | } 19 | } 20 | 21 | # Part 2: A series of Helpful Fuctions 22 | 23 | #1.function that print all recipe names 24 | def printRecipeName(menu) : 25 | for recipeName in menu.keys(): 26 | print(f'{recipeName}') 27 | 28 | #2.function that takes a recipe name and print its details 29 | def printRecipeDetails(recipeName, menu): 30 | for name in menu.keys() : 31 | if name == recipeName : 32 | print(f'Recipe for {recipeName} is') 33 | for key, details in menu[name].items() : 34 | print(f'{key} : {details}') 35 | 36 | #3.function that takes a recipe name and delete it 37 | def deleteRecipe(recipeName, menu): 38 | for name in menu.keys(): 39 | if name == recipeName: 40 | recipeToDelete = name 41 | break 42 | del menu[recipeToDelete] 43 | 44 | #4.function that add a recipe from uset input 45 | def addRecipe(cookbook): 46 | name = input("Enter a name:\n") 47 | 48 | ingredients = [] 49 | print("Enter ingredients:") 50 | while True : 51 | item = input() 52 | if(item == ""): 53 | break 54 | ingredients.append(item) 55 | 56 | mealType = input("Enter a meal type:\n") 57 | 58 | prepTime = input("Enter a preparation time:\n") 59 | 60 | while(not prepTime.isdigit()): 61 | print("\nyou should intput time as digits!\n") 62 | prepTime = input("Enter a preparation time:\n") 63 | 64 | prepTime = int(prepTime) 65 | 66 | newRecipe = { 67 | 'ingredients' : ingredients, 68 | 'meal' : mealType, 69 | 'prep_time' : prepTime 70 | } 71 | 72 | cookbook[name] = newRecipe 73 | 74 | def print_availble_list(): 75 | print("List of availble option!\n\t1: Add a recipe\n\ 76 | \t2: Delete a recipe\n\ 77 | \t3: Print a recipe\n\ 78 | \t4: Print the cookbook\n\ 79 | \t5: Quit\n") 80 | 81 | def switch(option): 82 | if option == "1": 83 | addRecipe(cookbook) 84 | elif option == "2": 85 | print("Please enter a recipe name you want to delete:") 86 | name = input(">> ") 87 | deleteRecipe(name ,cookbook) 88 | elif option == "3": 89 | print("Please enter a recipe name to get its detatls:") 90 | name = input(">> ") 91 | printRecipeDetails(name, cookbook) 92 | elif option == "4": 93 | printRecipeName(cookbook) 94 | elif option == "5": 95 | print("\nCookbook closed. Goodbye !") 96 | return ("Quit") 97 | 98 | def run_cookbook(cookbook): 99 | print("Welcom to this Python Cookbook !") 100 | print_availble_list() 101 | while True: 102 | print("Please select an option:") 103 | option = input(">> ") 104 | if (not option.isdigit() or (option.isdigit() and (int(option) > 5 or int(option) < 1))): 105 | print("\nSorry, this option does not exist.") 106 | print_availble_list() 107 | if (switch(option) == "Quit"): 108 | return 0 109 | 110 | run_cookbook(cookbook) -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex07/filterwords.py: -------------------------------------------------------------------------------- 1 | import string 2 | import sys 3 | 4 | def remove_puctuation(s): 5 | deletetion_symbols = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' 6 | newStr = "" 7 | for c in s: 8 | if c not in deletetion_symbols: 9 | newStr += c 10 | return newStr 11 | 12 | length = len(sys.argv) 13 | if (not length == 3) or not sys.argv[2].isdigit(): 14 | print("ERROR") 15 | exit() 16 | 17 | splitLst = remove_puctuation(sys.argv[1]).split() 18 | lst = [] 19 | for i in range(len(splitLst)): 20 | if len(splitLst[i]) > int(sys.argv[2]): 21 | lst.append(splitLst[i]) 22 | print(lst) -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex08/sos.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | morse_code_dict = { 4 | 'A': '.-', 'B': '-...', 'C': '-.-.', 5 | 'D': '-..', 'E': '.', 'F': '..-.', 6 | 'G': '--.', 'H': '....', 'I': '..', 7 | 'J': '.---', 'K': '-.-', 'L': '.-..', 8 | 'M': '--', 'N': '-.', 'O': '---', 9 | 'P': '.--.', 'Q': '--.-', 'R': '.-.', 10 | 'S': '...', 'T': '-', 'U': '..-', 11 | 'V': '...-', 'W': '.--', 'X': '-..-', 12 | 'Y': '-.--', 'Z': '--..', 13 | '0': '-----', '1': '.----', '2': '..---', 14 | '3': '...--', '4': '....-', '5': '.....', 15 | '6': '-....', '7': '--...', '8': '---..', 16 | '9': '----.' 17 | } 18 | def to_morse_code(text): 19 | morseCode = '' 20 | for c in text.upper(): 21 | if c in morse_code_dict: 22 | morseCode += morse_code_dict[c] + ' ' 23 | elif c == ' ': 24 | morseCode += '/ ' 25 | else : 26 | return "ERROR" 27 | return morseCode 28 | 29 | print(to_morse_code(" ".join(sys.argv[1::]))) if len(sys.argv) > 1 else print("invalid arguments!") -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex09/guess.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def guessGame() -> str: 4 | 5 | print("This is an interactive guessing game! \n\ 6 | You have to enter a number between 1 and 99 to find out the secret number.\n\ 7 | Type 'exit' to end the game.\n\ 8 | Good luck!\n") 9 | 10 | r = random.randint(1, 10) 11 | check = True 12 | count = 0 13 | while check: 14 | try: 15 | guessNumber = input("What's your guess between 1 and 99?\n>> ") 16 | if (guessNumber == "exit"): 17 | return "Goodbye!" 18 | guessNumber = int(guessNumber) 19 | count += 1 20 | if guessNumber > r: 21 | print("Too high!") 22 | elif guessNumber < r: 23 | print("Too low!") 24 | else : 25 | if r == 42: 26 | print("The answer to the ultimate question of life, the universe and everything is 42.") 27 | if count == 1: 28 | return "Congratulations! You got it on your first try!" 29 | return f'Congratulations, you\'ve got it!\nYou won in {count} attempts!' 30 | except ValueError: 31 | print("That's not a number.") 32 | 33 | print(guessGame()) -------------------------------------------------------------------------------- /PiscinePython42/Day00/ex10/loading.py: -------------------------------------------------------------------------------- 1 | from tqdm import tqdm 2 | 3 | 4 | for i in tqdm(range(int(9e6)), ncols=150): 5 | pass -------------------------------------------------------------------------------- /PiscinePython42/Day01/en.subject (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day01/en.subject (1).pdf -------------------------------------------------------------------------------- /PiscinePython42/Day02/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day02/en.subject.pdf -------------------------------------------------------------------------------- /PiscinePython42/Day03/en.subject (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day03/en.subject (1).pdf -------------------------------------------------------------------------------- /PiscinePython42/Day04/en.subject.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/PiscinePython42/Day04/en.subject.pdf -------------------------------------------------------------------------------- /Projects/SnakeGame/main.py: -------------------------------------------------------------------------------- 1 | #import modules necessary for the game 2 | import random 3 | import curses 4 | 5 | # Initialize the curses library to create our screen 6 | screen = curses.initscr() 7 | 8 | # Hide the mouse cursor 9 | curses.curs_set(0) 10 | 11 | # Getmax screen height and width 12 | screen_height, screen_width = screen.getmaxyx() 13 | 14 | # Create a new window 15 | window = curses.newwin(screen_height, screen_width, 0, 0) 16 | 17 | # Allow window to receive input from the keyboard 18 | window.keypad(1) 19 | 20 | # Set the delay for updating the screen 21 | window.timeout(30) 22 | 23 | # Set the x,y coordinates of the initial position of snake's head 24 | __snkX = screen_width // 4 25 | __snkY = screen_height // 2 26 | 27 | # define the initial position of the snake body 28 | __snake = [ 29 | [__snkY, __snkX], 30 | [__snkY, __snkX - 1], 31 | [__snkY, __snkX - 2] 32 | ] 33 | 34 | # Create the food in the middle of window 35 | food = [screen_height // 2, screen_width // 2] 36 | 37 | window.addch(food[0], food[1], curses.ACS_BLOCK) 38 | 39 | # Set initial movement direction to right 40 | key = curses.KEY_RIGHT 41 | 42 | # Create game loop that loops forever until player loses or quits the game 43 | 44 | while True: 45 | #get the next key that will be pressed by user 46 | next_key = window.getch() 47 | #If user doesn't input anything, key remains same, else key will be set to the new pressed key 48 | key = key if next_key == -1 else next_key 49 | # Check if snake collided with the walls or itself 50 | if __snake[0][0] in [0, screen_height] or __snake[0][1] in [0, screen_width] or __snake[0] in __snake[1:]: 51 | curses.endwin() 52 | quit() 53 | # Set the new poisition of the snake head based on te direction 54 | new_head = [__snake[0][0], __snake[0][1]] 55 | if key == curses.KEY_DOWN: 56 | new_head[0] += 1 57 | if key == curses.KEY_UP: 58 | new_head[0] -= 1 59 | if key == curses.KEY_RIGHT: 60 | new_head[1] += 1 61 | if key == curses.KEY_LEFT: 62 | new_head[1] -= 1 63 | __snake.insert(0, new_head) 64 | # Check if snake ate the food 65 | if __snake[0] == food: 66 | food = None # Remove food if snake ate it 67 | while food is None: 68 | new_food = [ 69 | random.randint(1, screen_height - 1), 70 | random.randint(1, screen_width - 1) 71 | ] 72 | food = new_food if new_food not in __snake else None 73 | window.addch(food[0], food[1], curses.ACS_BLOCK) 74 | else: 75 | # Otherwise remove the last segment of snake body 76 | tail = __snake.pop() 77 | window.addch(tail[0], tail[1], ' ') 78 | window.addch(__snake[0][0], __snake[0][1], curses.ACS_CKBOARD) 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /Projects/TransletApp/textToSpeech.py: -------------------------------------------------------------------------------- 1 | #pip install gTTs 2 | from gtts import gTTS 3 | 4 | #data 5 | txt = "welcome in my channel zakaria" 6 | langue = 'en' 7 | 8 | #pass data as parameter 9 | res = gTTS(text=txt, lang=langue) 10 | res.save("audio.mp3") -------------------------------------------------------------------------------- /Projects/TransletApp/translet_app.py: -------------------------------------------------------------------------------- 1 | #pip install translator - translate 2 | 3 | import translate 4 | from translate import Translator 5 | 6 | data = Translator(from_lang="French", to_lang="English") 7 | res = data.translate("merci") 8 | print(res) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # learn_python -------------------------------------------------------------------------------- /conda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function which_dl { 3 | # If operating system name contains Darwnin: MacOS. Else Linux 4 | if uname -s | grep -iqF Darwin; then 5 | echo "Miniconda3-latest-MacOSX-x86_64.sh" 6 | else 7 | echo "Miniconda3-latest-Linux-x86_64.sh" 8 | fi 9 | } 10 | 11 | function which_shell { 12 | # if $SHELL contains zsh, zsh. Else Bash 13 | if echo $SHELL | grep -iqF zsh; then 14 | echo "zsh" 15 | else 16 | echo "bash" 17 | fi 18 | } 19 | 20 | function when_conda_exist { 21 | # check and install 42AI environement 22 | printf "Checking 42AI-$USER environment: " 23 | if conda info --envs | grep -iqF 42AI-$USER; then 24 | printf "\e[33mDONE\e[0m\n" 25 | else 26 | printf "\e[31mKO\e[0m\n" 27 | printf "\e[33mCreating 42AI environnment:\e[0m\n" 28 | conda update -n base -c defaults conda -y 29 | conda create --name 42AI-$USER python=3.7 jupyter numpy pandas pycodestyle -y 30 | fi 31 | } 32 | 33 | function set_conda { 34 | MINICONDA_PATH="/goinfre/$USER/miniconda3" 35 | CONDA=$MINICONDA_PATH"/bin/conda" 36 | PYTHON_PATH=$(which python) 37 | REQUIREMENTS="jupyter numpy pandas pycodestyle" 38 | SCRIPT=$(which_dl) 39 | MY_SHELL=$(which_shell) 40 | DL_LINK="https://repo.anaconda.com/miniconda/"$SCRIPT 41 | DL_LOCATION="/tmp/" 42 | printf "Checking conda: " 43 | TEST=$(conda -h 2>/dev/null) 44 | if [ $? == 0 ]; then 45 | printf "\e[32mOK\e[0m\n" 46 | when_conda_exist 47 | return 48 | fi 49 | printf "\e[31mKO\e[0m\n" 50 | if [ ! -f $DL_LOCATION$SCRIPT ]; then 51 | printf "\e[33mDonwloading installer:\e[0m\n" 52 | cd $DL_LOCATION 53 | curl -LO $DL_LINK 54 | cd - 55 | fi 56 | printf "\e[33mInstalling conda:\e[0m\n" 57 | sh $DL_LOCATION$SCRIPT -b -p $MINICONDA_PATH 58 | printf "\e[33mConda initial setup:\e[0m\n" 59 | $CONDA init $MY_SHELL 60 | $CONDA config --set auto_activate_base false 61 | printf "\e[33mCreating 42AI-$USER environnment:\e[0m\n" 62 | $CONDA update -n base -c defaults conda -y 63 | $CONDA create --name 42AI-$USER python=3.7 jupyter numpy pandas pycodestyle -y 64 | printf "\e[33mLaunch the following command or restart your shell:\e[0m\n" 65 | if [ $MY_SHELL == "zsh" ]; then 66 | printf "\tsource ~/.zshrc\n" 67 | else 68 | printf "\tsource ~/.bash_profile\n" 69 | fi 70 | } 71 | set_conda -------------------------------------------------------------------------------- /course/ForLoop.py: -------------------------------------------------------------------------------- 1 | for char in "string": 2 | print(char) 3 | 4 | for x in range(10): 5 | print(x) 6 | 7 | buddies = ["piko", "grand", "sub"] 8 | for index in range(len(buddies)): 9 | print(buddies[index]) 10 | 11 | for buddy in buddies: 12 | if buddy == "sub": 13 | print(buddy, " is your friend") 14 | break 15 | else: 16 | print("not found") -------------------------------------------------------------------------------- /course/Functions.py: -------------------------------------------------------------------------------- 1 | name = input("enter your name : ") 2 | age = input("enter your age : ") 3 | 4 | def __SayHey(name, age): 5 | print("hello " + name + " your age is : " + str(age)) 6 | 7 | __SayHey(name, 23) 8 | 9 | def cube(num): 10 | return num*num*num 11 | 12 | result = cube(3) 13 | 14 | print("cube 3 is : "+ str(result)) 15 | 16 | # power function 17 | 18 | print(3**6) 19 | 20 | def power(base_num, pow_num): 21 | result = 1 22 | for index in range(pow_num): 23 | result = result * base_num 24 | return result 25 | 26 | print(power(3, 6)) 27 | -------------------------------------------------------------------------------- /course/GetingInput.py: -------------------------------------------------------------------------------- 1 | name = input("enter your name : ") 2 | age = input("enter your age : ") 3 | print("hello " + name + "your age is " + age) 4 | 5 | #Callcul App 6 | 7 | num1 = input("enter number : ") 8 | num2 = input("enter number : ") 9 | 10 | result = float(num1) + int(num2) 11 | print(result) -------------------------------------------------------------------------------- /course/IfStatement.py: -------------------------------------------------------------------------------- 1 | # or, and, and not 2 | 3 | #syntax 4 | # if v1and v2 5 | # do somethings 6 | #elif v1 and not v2 7 | # do somethings else 8 | #elif not v1 and v2 9 | # do something 10 | # else 11 | # somthing else 12 | 13 | def mathc_string(str1, str2): 14 | if str1 == str2: 15 | print("the strings do match") 16 | else: 17 | print("the string dont match") 18 | 19 | mathc_string("zack", "zakaria") -------------------------------------------------------------------------------- /course/Lists.py: -------------------------------------------------------------------------------- 1 | friends = [1, "codezilla", True , False, [1, "islam"]] 2 | Family = ["html", "css", "javascript"] 3 | print(friends) 4 | print(friends[4][1]) 5 | print(friends[1:]) 6 | print(friends[1:4]) 7 | 8 | # friends += Family 9 | friends.extend(Family) # the same thingf 10 | print(friends) 11 | friends.append("python3") 12 | print(friends) 13 | friends.insert(9, "PHP") 14 | print(friends) 15 | friends.remove("codezilla") 16 | print(friends) 17 | whatWasPoped = friends.pop() 18 | print(whatWasPoped) 19 | print(friends.index("html")) 20 | print(friends.count("javascript")) 21 | # friends.sort() must be all same type 22 | 23 | friends_copy = friends.copy() # Shallow copy 24 | print(friends) 25 | print(friends_copy) 26 | friends.clear() 27 | print(friends) 28 | -------------------------------------------------------------------------------- /course/Set.py: -------------------------------------------------------------------------------- 1 | numbers = {4,3,2,1,1,1,1,4,4,4,4,2,3} 2 | 3 | name = "iiiissssslllllaaaam" 4 | 5 | unique_set = set(name) 6 | 7 | print(unique_set) 8 | 9 | unique = [] 10 | 11 | for number in numbers: 12 | if number not in unique: 13 | unique.append(number) 14 | 15 | print(dir(unique)) -------------------------------------------------------------------------------- /course/Stringd.py: -------------------------------------------------------------------------------- 1 | text = "zackz" 2 | age = 4 3 | print(text.index("z")) 4 | print(len(text)) 5 | print(text.replace("zack", "zakaria")) 6 | print(str(age) + " may age") 7 | -------------------------------------------------------------------------------- /course/TryExcept.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/course/TryExcept.py -------------------------------------------------------------------------------- /course/Tuples.py: -------------------------------------------------------------------------------- 1 | coordinates = (23, 34) # const 2 | print(coordinates) 3 | print(coordinates[0]) -------------------------------------------------------------------------------- /course/classAndObject/Doctor.py: -------------------------------------------------------------------------------- 1 | class Doctor: 2 | def studied_years(self): 3 | print("i studied 7 years") 4 | def paid_by_who(self): 5 | print("i get paid by the governemet") 6 | 7 | class FamilyDoctor(Doctor): 8 | def paid_by_who(self): 9 | print("i get paid by the people") -------------------------------------------------------------------------------- /course/classAndObject/Employee.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | def __init__(self, name, age, department, is_manger, rating): 3 | self.name = name 4 | self.age = age 5 | self.department = department 6 | self.is_manger = is_manger 7 | self.rating = rating #rating from 1-5 8 | 9 | def is_excellent(self): 10 | return True if self.rating >= 4.5 else False -------------------------------------------------------------------------------- /course/classAndObject/__pycache__/Doctor.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmoussam/Piscine-python42/ef2139a434422caa9549842ea773efe9d47f7dd2/course/classAndObject/__pycache__/Doctor.cpython-39.pyc -------------------------------------------------------------------------------- /course/classAndObject/classAndObject.py: -------------------------------------------------------------------------------- 1 | from Employee import Employee 2 | 3 | em1 = Employee("islam", 50, "Codezilla", True, 5) 4 | em2 = Employee("ibrahim", 60, "Facebook", False, 3.5) 5 | 6 | print(em1.name, em2.age) 7 | print(em1.is_excellent()) -------------------------------------------------------------------------------- /course/classAndObject/inheritance.py: -------------------------------------------------------------------------------- 1 | from Doctor import Doctor 2 | from Doctor import FamilyDoctor 3 | 4 | d1 = Doctor() 5 | d2 = FamilyDoctor() 6 | 7 | d1.paid_by_who() 8 | d2.paid_by_who() 9 | d2.studied_years() 10 | -------------------------------------------------------------------------------- /course/conda.txt: -------------------------------------------------------------------------------- 1 | # install conda 2 | 3 | We recommend the following path for your conda folder. 4 | @> MYPATH="/goinfre/$USER/miniconda3" 5 | 6 | #Download & Install conda 7 | 8 | # For MAC 9 | @> curl -LO "https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" 10 | @> sh Miniconda3-latest-MacOSX-x86_64.sh -b -p $MYPATH 11 | # For Linux 12 | @> curl -LO "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" 13 | @> sh Miniconda3-latest-Linux-x86_64.sh -b -p $MYPATH 14 | 15 | # For zsh 16 | @> $MYPATH/bin/conda init zsh 17 | @> $MYPATH/bin/conda config --set auto_activate_base false 18 | @> source ~/.zshrc 19 | # For bash 20 | @> $MYPATH/bin/conda init bash 21 | @> $MYPATH/bin/conda config --set auto_activate_base false 22 | @> source ~/.bash_profile 23 | 24 | #Create an environment for 42AI ! 25 | 26 | @> conda create --name 42AI-$USER python=3.7 jupyter pandas pycodestyle numpy 27 | 28 | # Check your 42AI Python environment 29 | 30 | @> conda info --envs 31 | @> conda activate 42AI-$USER 32 | @> which python 33 | @> python -V 34 | @> python -c "print('Hello World!')" 35 | 36 | # install packages 37 | | 38 | |___________ _Defaulf channels 39 | |__ @> conda install _package_name 40 | | 41 | |___________ _Other 42 | |____@> conda instal -c channel_name package name 43 | |__ or we can add the channel to the default channels by : @> conda config -add channels _channel_name 44 | @> conda install _packege_name 45 | | 46 | |_________ to see all channels : @> conda config show channles 47 | 48 | # deactivate env 49 | | 50 | |______ $> conda @> deactivate -------------------------------------------------------------------------------- /course/fiveConcept.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Learn the 5 must-know concepts 3 | ''' 4 | #----1-----immutable vs mutable type 5 | 6 | # str | list 7 | # int | set 8 | # float | dict 9 | # bool | 10 | # bytes | 11 | # tuple | 12 | 13 | # x = (1, 2) 14 | # y = x 15 | # x = (1, 2, 3) 16 | # print(x, y) 17 | 18 | # x = [1, 2] 19 | # y = x 20 | # x[0] = 100 21 | # x = [9, 0] 22 | # print(x, y) 23 | 24 | # def get_largest_numbers(numbers, n): 25 | # numbers.sort() 26 | 27 | # return numbers[-n:] 28 | 29 | # nums = [2, 3, 4, 1, 34, 123, 321, 1] 30 | 31 | # print(nums) 32 | 33 | # largest = get_largest_numbers(nums, 2) 34 | # print(largest) 35 | # print(nums) 36 | 37 | #----2-----List comprehensions 38 | 39 | # x = [i for i in range(10)] 40 | # print(x) 41 | 42 | # x = [i for i in range(10) if i % 2 == 0] 43 | # print(x) 44 | 45 | #----3-----Fuction argument and parameter types 46 | 47 | def complicated_function(x, y, z = 10): 48 | print(x, y, z) 49 | pass 50 | 51 | def complicated_function2(*args , **kwargs): 52 | print(args, kwargs) 53 | pass 54 | 55 | def complicated_function3(a, b, c = True, d = False): 56 | print(a, b, c, d) 57 | pass 58 | 59 | complicated_function(1, y = 3) 60 | complicated_function2(1, 2, 3,4, a = "hey", b = 123) 61 | complicated_function3(*[1, 2], **{"c": "hello", "d" : "cool"}) 62 | 63 | #----4------if __name__ == "__main__": 64 | 65 | def add(a, b): 66 | return a + b 67 | 68 | if __name__ == "__main__": 69 | print("run") 70 | #we should import this module in an other file to see the difference -------------------------------------------------------------------------------- /course/readingFile.py: -------------------------------------------------------------------------------- 1 | fd = open("Lists.py", "r") 2 | print(fd.readable()) 3 | # print(fd.read()) 4 | print(fd.readline(), end='') 5 | print(fd.readlines()[0]) 6 | fd.close() -------------------------------------------------------------------------------- /course/writingFile.py: -------------------------------------------------------------------------------- 1 | fd = open("index.html", "w") 2 | fd.write("

nothing yet!

") 3 | fd.close() --------------------------------------------------------------------------------