Skip to content

Instantly share code, notes, and snippets.

View neosergio's full-sized avatar
🤓
Happy Coding!

Sergio Infante neosergio

🤓
Happy Coding!
View GitHub Profile
@neosergio
neosergio / install_pyenv.sh
Created October 31, 2021 21:11 — forked from jmvrbanac/install_pyenv.sh
Install pyenv on Ubuntu
#!/bin/bash
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc

Write a simple property

  • Write a simple Promo class. Its constructor receives two variables: name (which must be a string) and expires (which must be a datetime object).

  • Add a property called expired which returns a boolean value indicating whether the promo has expired or not.

Proposed solution

from datetime import datetime, timedelta

NOW = datetime.now()

Parse a list of Names

For the following list of names:

NAMES = ['arnold schwarzenegger', 'alec baldwin', 'bob belderbos',
         'julian sequeira', 'sandra bullock', 'keanu reeves',
         'julbob pybites', 'bob belderbos', 'julian sequeira',
         'al pacino', 'brad pitt', 'matt damon', 'Brad pitt']
@neosergio
neosergio / sum_n_numbers.md
Last active August 19, 2021 17:28
Python unit testing exercise

Sum of N numbers

Write a function that can sum up numbers:

  • It should receive a sequence of n numbers.
  • If no argument is provided, return sum of numbers 1..100.
  • Look closely to the type of the function's default argument ...

Proposed solution

def sum_numbers(numbers=None):
@neosergio
neosergio / PY0101EN-3-4-Classes.ipynb
Created July 20, 2019 16:09
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-3-3-Functions.ipynb
Created July 20, 2019 15:59
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-3-2-Loops.ipynb
Created July 20, 2019 15:26
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-3-1-Conditions.ipynb
Created July 20, 2019 15:07
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-2-4-Sets.ipynb
Created July 15, 2019 21:07
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neosergio
neosergio / PY0101EN-2-3-Dictionaries.ipynb
Created July 15, 2019 20:46
Created on Cognitive Class Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.