{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Q1 : Write a interactive program that takes user age as input and return `You're, not eligible.` if age is less than 21 else `Welcome!` if age is greater than or equal to 21.\n", "\n", "**Hint:** Ensure that no absurd age like -10, 0, 100, etc is specified. Age range should be (0, 80]. Also include necesary exception handling block to make your code robust." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q2 : Write a interactive program that takes three different numbers as user input and returns the maximum number.\n", "\n", "**Hint:** Do not use any built-in function, use opertors to compare values. Also, ensure that the numbers provided by user are all different." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Q3 : Try to solve Q2 using conditional expression.\n", "\n", "**Hint:**  ` if else `" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Q4 : The maximum speed is 50 if we are within the city, otherwise it is 100. Translate this to ternary Python statements.\n", "\n", "**Hint:**  Ternary operator are conditional expression. What if your speed is above 100? " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q5 : Write an interactive program that calculates the total pay for the week, taking into account overtime. Hours worked over 40 are overtime, paid at 1.5 times the normal rate. Hourly wage rate is `$15`.\n", "\n", "**Sample input1**: `45.6`\n", "\n", "**Sample output1:** `726.0`\n", "\n", "**Sample input1**: `40`\n", "\n", "**Sample output1:** `600.0`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q6 : Write a program that prompts students for how many credits they have. Print whether or not they have enough credits for graduation. (At Loyola University Chicago 120 credits are needed for graduation.)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q7 : Write an interactive program that asks the number between 1 and 10 and print if the number is `Even` or `Odd`. If the number is out of range the program should display \"invalid number\". " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q8 : You are a shopkeeper and to interact with your customers you have to write a program that helps your customers to place order. In case the item is not available then your program should display `Item not available` , otherwise it will display ` added to cart`. The items that are available currently as listed in the code cell below.\n", "\n", "**Hint:** Apple, apple, APPLE, apPle, etc. all refer to the same item `apple`.\n", "\n", "`product_list = ['apple', 'orange', 'milk', 'ham', 'bread', 'cheese']`\n", "\n", "**Sample input1**: `apple`\n", "\n", "**Sample output1:** `Apple added to cart`\n", "\n", "**Sample input1**: `flour`\n", "\n", "**Sample output1:** `Item not available`" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q9 : A leap year is a calendar year containing an additional day added to keep the calendar year synchronized with the astronomical or seasonal year. In the Gregorian calendar, each leap year has 366 days instead of 365, by extending February to 29 days rather than the common 28. These extra days occur in years which are multiples of four (with the exception of centennial years not divisible by 400). Write a Python program, which asks for a year and calculates, if this year is a leap year or not.\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q10 : Body mass index (BMI) is a value derived from the mass (weight) and height of a person. The BMI is defined as the body mass divided by the square of the body height, and is universally expressed in units of kg/m2, resulting from mass in kilograms and height in metres. \n", "\n", "#### BMI=$\\frac{m}{l^2}$\n", "\n", "### Write a program, which asks for the length and the weight of a person and returns an evaluation string according to the following table:\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ### \n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }