Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions # Exercício - Quiz.py

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
.ipynb_checkpoints/
.venv/
.env
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Python Studies

[Português](README.pt-BR.md)

Small Python exercises from my undergraduate studies in Information and Communication Technology (UFSC).

| File | What it is | Concepts |
|---|---|---|
| [`quiz_exercise.py`](quiz_exercise.py) | Command-line multiple-choice quiz | lists of dictionaries, `enumerate()`, input validation |
| [`data_visualization_final_project.ipynb`](data_visualization_final_project.ipynb) | Data Visualization course final project: exploratory analysis of international tourist arrivals in Brazil (2019) | pandas, seaborn, matplotlib, folium heat maps, geocoding with geopy |

## Running

```bash
python quiz_exercise.py
```

The notebook was written for Google Colab: use the **Open in Colab** badge at its top. It reads CSV files from a Google Drive folder, so update the paths to your own copy of the datasets.
18 changes: 18 additions & 0 deletions README.pt-BR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Estudos de Python

[English](README.md)

Exercícios de Python da graduação em Tecnologias da Informação e Comunicação (UFSC).

| Arquivo | O que é | Conceitos |
|---|---|---|
| [`quiz_exercise.py`](quiz_exercise.py) | Quiz de múltipla escolha no terminal | listas de dicionários, `enumerate()`, validação de entrada |
| [`data_visualization_final_project.ipynb`](data_visualization_final_project.ipynb) | Trabalho final da disciplina de Visualização de Dados: análise exploratória das chegadas de turistas internacionais ao Brasil (2019) | pandas, seaborn, matplotlib, mapas de calor com folium, geocodificação com geopy |

## Como rodar

```bash
python quiz_exercise.py
```

O notebook foi feito para o Google Colab: use o botão **Open in Colab** no topo dele. Ele lê arquivos CSV de uma pasta do Google Drive, então ajuste os caminhos para a sua cópia dos dados.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/CarolDekker/EstudosPython/blob/main/Trabalho_Final_DataVis.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
"<a href=\"https://colab.research.google.com/github/CarolDekker/python-studies/blob/main/data_visualization_final_project.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
Expand Down
47 changes: 47 additions & 0 deletions quiz_exercise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Quiz exercise: multiple-choice questions stored in a list of dictionaries.
# Goal: practice dictionaries, lists, enumerate() and input validation.

questions = [
{
"question": "What is 2 + 2?",
"options": ["1", "3", "4", "5"],
"answer": "4",
},
{
"question": "What is 5 * 5?",
"options": ["25", "55", "10", "51"],
"answer": "25",
},
{
"question": "What is 10 / 2?",
"options": ["4", "5", "2", "1"],
"answer": "5",
},
]

correct = 0
for item in questions:
print(item["question"])
# enumerate() returns (position, value) pairs
for position, option in enumerate(item["options"]):
print(f"{position}) {option}")
if option == item["answer"]:
correct_position = position

reply = input("Choose an option: ")

if not reply.isdigit():
print("Numbers only!")
break

choice = int(reply)
last_option = len(item["options"]) - 1
if choice < 0 or choice > last_option:
print(f"Only options 0 to {last_option}!")
elif choice == correct_position:
correct += 1
print("Correct!")
else:
print("Wrong answer.")

print(f"TOTAL: {correct}/{len(questions)}")