# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/wecchi/univesp_com200/blob/main/Sem2/Exercicios.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="1fflCIq28n1-"
# Calcular a média na disciplia

# + colab={"base_uri": "https://localhost:8080/"} id="oLP731uZ8HZK" outputId="70cf7948-bb30-4750-d164-689d664f5349"
disciplina = "Formação Profissional em Computação"
semanas = 8
nota1 = 9.0
nota2 = 7.0
media = nota1 * 0.4 + nota2 * 0.6
print("Média de aproveitamento na disciplina {}: {:.2f}".format(disciplina, media))

# + colab={"base_uri": "https://localhost:8080/"} id="r0PnMDnp-XHO" outputId="510a0ed0-ab90-4c22-d9d7-9adf132eb02d"
print(f'Total de semanas: {semanas}')


# + [markdown] id="3hjv7oPN-5je"
# Vamos declarar uma função para calcular a média

# + id="RIhnlG5A_CLM"
def media_final(n1, n2):
  return round((n1 + n2)/2,2)


# + colab={"base_uri": "https://localhost:8080/"} id="HctnE_2C_g1J" outputId="719b67e3-345f-4c52-e3a7-89ad737d6ecd"
media_final(7.8, 9.9)


# + id="8x4H0p2o_3V3"
def criptize():
  palavra = input("Informa a palavra a ser criptografada: ")
  letras = list(palavra)
  to_cript = ''
  for letra in letras:
    if (letra == 'z'):to_cript+='a'
    elif (letra == 'Z'):to_cript+='A'
    else: to_cript+=chr(ord(letra)+1)
  return to_cript


# + colab={"base_uri": "https://localhost:8080/", "height": 53} id="2tlpOKisBjYI" outputId="025598e5-e439-4bc0-d05d-3265d19be64b"
criptize()


# + id="EILPMYJoCJjG"
def decriptize()


# + colab={"base_uri": "https://localhost:8080/"} id="ZiKnElXBCVCV" outputId="7043ecdb-de88-4e96-8786-a78fbcabd5b9"
# Exemplo de lista
lista_notas = [10, 8.9, 9.9, 10, 10]
lista_notas[2]

# + colab={"base_uri": "https://localhost:8080/", "height": 35} id="IVQejcUxCVWz" outputId="db00f8b4-d7d7-401a-d21e-3c7e055abde8"
# Exemplo de dicionário
dicionario_alunos = {"nome":"<NAME>", "idade":38}
dicionario_alunos["nome"]

# + [markdown] id="1L1TtDFqE-gJ"
# # Utilizando biblioteca Pandas

# + colab={"base_uri": "https://localhost:8080/", "height": 195} id="kuN8OSH6CVk8" outputId="85773e2c-8912-48dd-f47e-23f96ef9fd92"
import pandas as pd
url = "https://raw.githubusercontent.com/fivethirtyeight/data/master/alcohol-consumption/drinks.csv"
bebidas = pd.read_csv(url, error_bad_lines=False, encoding='latin-1')
bebidas.head()

# + colab={"base_uri": "https://localhost:8080/"} id="Mt7tTzn6DtyB" outputId="c6c5ac8c-d174-493a-a3f9-7bca756171c2"
bebidas.columns = ["pais", "cervejas", "destilados", "vinhos", "total"]
bebidas["total"].mean()

# + colab={"base_uri": "https://localhost:8080/", "height": 386} id="hmoQvN2aKg7G" outputId="7733356b-5add-47dc-885b-25029530b025"
bebidas.filter(like='Brasil', axis=0)

# + colab={"base_uri": "https://localhost:8080/", "height": 284} id="ysynvPbtDttg" outputId="fd39a12c-f7a9-4e28-a05a-40653d560df2"
bebidas.describe()

# + colab={"base_uri": "https://localhost:8080/", "height": 285} id="57oj-s3aF5YQ" outputId="a6129033-fd2a-4495-fa8d-d2f847e51c4a"
import seaborn as sns
bebidas[["cervejas", "destilados", "vinhos"]].plot(kind='hist')

# + colab={"base_uri": "https://localhost:8080/", "height": 282} id="hInqNlv1GLHW" outputId="d84c3ab8-bca5-4105-f767-1fd614754580"
bebidas.median().plot()

# + id="AP9QDVt5GLQs"
uri = "https://raw.githubusercontent.com/fivethirtyeight/data/master/covid-geography/mmsa-icu-beds.csv"
dados = pd.read_csv(uri)
dados.columns=["Área", "Grupo_de_risco", "Pessoas_de_risco/UTI", "Pessoas_de_risco/Hospital", "Leitos_UTI", "Hospitais", "Pessoas_em_risco"]

# + colab={"base_uri": "https://localhost:8080/", "height": 195} id="ejsZvGntGLTc" outputId="c57346b1-6516-4d8d-fc5a-f57f42c500b8"
dados.head()

# + colab={"base_uri": "https://localhost:8080/", "height": 77} id="_WfviKbPGLVy" outputId="6180608b-92ff-44ba-a023-db09b65230f6"
dados[dados["Pessoas_em_risco"] == dados["Pessoas_em_risco"].max()]

# + colab={"base_uri": "https://localhost:8080/"} id="0c5bbQIfGLXn" outputId="5cfbde45-0824-4d8f-a3ab-ae12de4af79d"
for i in dados["Pessoas_em_risco"]:
  if (i == dados["Pessoas_em_risco"].max()):
    print('Maior pessoas em risco {}'.format(i))
    exit

StarcoderdataJupyterScriptsDedupFiltered