{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab 1\n", "(Prof. Carlos J. Costa)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**1)** Verify if a value is integer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**2)** Verify if a value is even" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**3)** Insert two numbers. Is the first is bigger than the second?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**4)** Verify if one value is multiple of another" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**5)** Calculate the interest earn by an investor that \n", "invested a capital of 200 during 3 years with an interest rate of 3%. \n", "(I= P\\*R\\*T)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**6)** Capital that an investor obtained after \n", "investing a capital of 200 during 3 years with an interest rate of 3%. (Compound interest)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**7)** Calculate your BMI (Body Mass Index) \n", " \n", "$BMI = mass (kg)/height^2 (m)$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**8)** Calcule the Golden ration: \n", " \n", "$gr=(1+\\sqrt{5})/2$\n", "\n", "1. Solve the problem without using libraries\n", "2. Use module math (import math) and function sqr (math.sqrt)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**9)** Calculete the NPV (Net present value) of an investment, considering an initial investment of 10000, the following Cashflows 2000,3000, 4000, 4000 and 5000 and a discount rate of 10%.\n", "\n", "$NPV = \\sum_{t=1}^{n}\\frac{FV_{t}}{(1 + k)^{t}} – I$\n", "\n", "Where:\n", "\n", "FV = Future cost of the cash inflows,\n", "I = Initial Investment\n", "k = Discount rate equal to the owner’s cost of capital\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**10)** Ask the user to insert name and age. Calculate the the birth. Print a result saying the 'this person was born in'\n", "1. Solve the problem without using modules and libraries\n", "2. Solve the problem using the date library from module datetime, as fallow:\n", " \n", "```python\n", "from datetime import date \n", "today = date.today() \n", "today.year \n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**11)** Ask the user to insert forenames, surnames. create a new variable (name) with your complete name.\n", " \n", "Create the follwoing variables: \n", " \n", "**nameBig**, where all the characters of the name are capitalized \n", "**nameTitle**, where the only the first character of each name (word) is capitalized \n", "**nameSmall**, where all the characters of the name are lower \n", "**nameCapitalized**, where only the first charater of the first name is capitalized " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**12)** Use the follwoing method to show where in which carater appears the firs \"da\"\n", " \n", "```python\n", "str.find(sub,start,end)\n", "```\n", " \n", "What happens if does not find?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Code here" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 2 }