From bfa0be00edbae0438dc910f8e4a3a224c4949385 Mon Sep 17 00:00:00 2001 From: vedantsahu19 <45250205+vedantsahu19@users.noreply.github.com> Date: Thu, 22 Nov 2018 09:25:42 +0530 Subject: [PATCH] Add files via upload --- vedant sahu(E18ECE044) LAB 1.ipynb | 623 +++++++++++++++++++++++++++++ 1 file changed, 623 insertions(+) create mode 100644 vedant sahu(E18ECE044) LAB 1.ipynb diff --git a/vedant sahu(E18ECE044) LAB 1.ipynb b/vedant sahu(E18ECE044) LAB 1.ipynb new file mode 100644 index 0000000..c049fe7 --- /dev/null +++ b/vedant sahu(E18ECE044) LAB 1.ipynb @@ -0,0 +1,623 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "HXDCF1BicfN8" + }, + "source": [ + "# Lab Assignment 1: Introduction to Python" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Important Points:\n", + "### For executing the code of block, press Shift + Enter.\n", + "### For comment use #." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "CzYaWy7gcfN-" + }, + "source": [ + "### Problem 1: Write a program to print \"HELLO PYTHON !\"" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "7sG2pSrdcfN_" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello Python\n" + ] + } + ], + "source": [ + "# write your code after this line\n", + "print('Hello Python')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "ck-2rEF4cfOC" + }, + "source": [ + "### Problem 2: Write a program to run the below code and try to make some changes such as country name, etc." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "Y0tRnGsQcfOD" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I am from INDIA\n", + "I love INDIA\n", + "I love INDIA\n", + "My state name is : TELANGANA\n" + ] + } + ], + "source": [ + "print('I am from INDIA')\n", + "print(\"I love INDIA\")\n", + "print(\"I love \"+ 'INDIA')\n", + "print(\"My state name is : \"+ \"TELANGANA\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "FtY6brB4cfOG" + }, + "source": [ + "### Problem 3:\n", + "#### Task1: Write a program to run the below code and try to make some changes to the program." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "QJyZcQ3VcfOH" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I am from INDIA\n", + "I love INDIA\n", + "I love INDIA\n", + "My state name is : TELANGANA\n", + "ABHISHEK is 18 year old\n", + "Yeah me too.!\n" + ] + } + ], + "source": [ + "country='INDIA'\n", + "state=\"TELANGANA\"\n", + "age=18\n", + "name=\"ABHISHEK\"\n", + "\n", + "print('I am from', country)\n", + "print('I love '+ country)\n", + "print(\"I love \"+ country)\n", + "print(\"My state name is : \"+ state)\n", + "\n", + "print(name, 'is', age, 'year old')\n", + "print(\"Yeah me too.!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "2w4vNRIrcfOK" + }, + "source": [ + "#### Task2: Write a program to display your infomation like (full name, branch, university name, Age, 12th %, hobbies). Store each value into some meaningful variable. The ouptput of the program should look like:" + ] + }, + { + "cell_type": "raw", + "metadata": { + "colab_type": "raw", + "id": "hnveJccYcfOL" + }, + "source": [ + "My name is :\n", + "I am in ECE branch at Bennett University : \n", + "I am 18 year old : \n", + "My Higher Secondary % is :\n", + "My hobbies are : " + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "eGTWJHDicfOM" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "My name is Gaurav\n", + "I am in CSE branch at BENNETT UNIVERSITY\n", + "I am 18 year old\n", + "My higher secondfary education % is 90.5\n", + "My hobbies are playing football,social media\n" + ] + } + ], + "source": [ + "# write your code after this line\n", + "name=\"Gaurav\"\n", + "age=18\n", + "clg='BENNETT UNIVERSITY'\n", + "marks=90.5\n", + "hobbies= 'playing football,social media'\n", + "print('My name is',name)\n", + "print('I am in CSE branch at',clg)\n", + "print('I am',age,'year old')\n", + "print('My higher secondfary education % is',marks)\n", + "print('My hobbies are',hobbies)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "vclGyZbZcfOP" + }, + "source": [ + "### Problem 4: Write a program to perform arithmetic operations (Addition, Subtraction, Multiplication, Division) on two integer numbers. The output of the program should look like:" + ] + }, + { + "cell_type": "raw", + "metadata": { + "colab_type": "raw", + "id": "JWXZHrlwcfOQ" + }, + "source": [ + "First number = \n", + "Second number = \n", + "Addition : \n", + "Subtraction : \n", + "Multiplication : \n", + "Division : " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "wArpl58_cfOQ" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "30\n", + "10\n", + "200\n", + "2.0\n" + ] + } + ], + "source": [ + "number1=20\n", + "number2=10\n", + "\n", + "# write your code after this line\n", + "# num = number1 + number2\n", + "print(number1+number2)\n", + "print(number1-number2)\n", + "print(number1*number2)\n", + "print(number1/number2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "P07eBi4KcfOU" + }, + "source": [ + "### Problem 5: Write a run the below code." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "xLI1U8RJcfOU" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter your first name: ABHISHEK\n", + "Enter your second name: N\n", + "Enter your semester: FIRST\n", + "Hello friends my name is ABHISHEK N and I am in FIRST semester\n" + ] + } + ], + "source": [ + "firstname=input(\"Enter your first name: \")\n", + "lastname=input(\"Enter your second name: \")\n", + "semester=input(\"Enter your semester: \")\n", + "fullname=firstname + \" \" +lastname\n", + "print(\"Hello friends my name is \",fullname, \" and I am in \", semester, \"semester\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "AJSWrElpcfOZ" + }, + "source": [ + "### Problem 6 : Write a program to swap the contents of two variables using third variable. The output of the program should look like:" + ] + }, + { + "cell_type": "raw", + "metadata": { + "colab_type": "raw", + "id": "fVL5tp7XcfOa" + }, + "source": [ + "Before swapping:\n", + "First Value: 90\n", + "Second Value: 10\n", + "\n", + "After swapping:\n", + "First Value: 10\n", + "Second Value: 90" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "u04a0hQXcfOa" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "first value 10\n", + "second value 90\n" + ] + } + ], + "source": [ + "first_value=90\n", + "second_value=10\n", + "# write your code after this line ...\n", + "t=first_value\n", + "first_value=second_value\n", + "second_value=t\n", + "print(\"first value\",first_value)\n", + "print(\"second value\",second_value)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "ei6J38xOcfOd" + }, + "source": [ + "### Problem 7 : The wheel of a bullock cart has a radius of 6 m. If the wheel rotates once, write a program to determine how much distance does the cart move?" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "EJWEn5P4cfOd" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "enter radius6\n", + "37.68\n" + ] + } + ], + "source": [ + "# write your code after this line\n", + "r=int(input(\"enter radius\"))\n", + "dis=float(2*3.14*r)\n", + "print(dis)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "WqpIS574cfOf" + }, + "source": [ + "### Problem 8 : Write a program to evaluate the expression: 5x^2 + 10x + 5 and print the result. Take x=10, x=20, x=15" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "7j5pPawrcfOg" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "enter the value of x1:10\n", + "605\n", + "enter the value of x2:20\n", + "2205\n", + "enter the value of x3:15\n", + "1280\n" + ] + } + ], + "source": [ + "# write your code after this line\n", + "x1=int(input(\"enter the value of x1:\"))\n", + "t=5*x1**2+10*x1+5\n", + "print(t)\n", + "x2=int(input(\"enter the value of x2:\"))\n", + "t=5*x2**2+10*x2+5\n", + "print(t)\n", + "x3=int(input(\"enter the value of x3:\"))\n", + "t=5*x3**2+10*x3+5\n", + "print(t)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "bYbNt3tQcfOj" + }, + "source": [ + "### Problem 9 : Assume Sachin’s basic salary is 10 Lakh. His dearness allowance(DA) is 40% of basic salary, and house rent allowance(HRA) is 20% of basic salary. Write a program to calculate his gross salary." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "qGVyJALqcfOk" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "gross= 1600000.0\n" + ] + } + ], + "source": [ + "basic=1000000\n", + "da=0.40*basic\n", + "hra=0.20*basic\n", + "gross=basic+da+hra\n", + "print(\"gross=\",gross)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "Gi9VMcjCcfOm" + }, + "source": [ + "### Problem 10 : A cashier has currency notes of denominations 10, 50 and 100. Take an Input of a number for withdraw amount. Find the total number of currency notes of each denomination the cashier will have to give to the withdrawer. The output of the program should look like. Take some exmple to test your program." + ] + }, + { + "cell_type": "raw", + "metadata": { + "colab_type": "raw", + "id": "O_9_5QmTcfOn" + }, + "source": [ + "Enter amount to be withdrawn: 170\n", + "100 rupees note:1\n", + "50 rupees note:1\n", + "10 rupes note:2" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "colab": { + "autoexec": { + "startup": false, + "wait_interval": 0 + } + }, + "colab_type": "code", + "id": "7qAlMz35cfOo" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "enter the amount to be withdrawn in multiple of 10 14520\n", + "hundred rupee notes 145\n", + "fifty rupee notes 0\n", + "ten rupee notes 2\n" + ] + } + ], + "source": [ + "# write your code after this line\n", + "w=int(input(\"enter the amount to be withdrawn in multiple of 10 \"))\n", + "h=w//100\n", + "r=w%100\n", + "f=r//50\n", + "r2=r%50\n", + "t=r2//10\n", + "print(\"hundred rupee notes\",h)\n", + "print(\"fifty rupee notes\",f)\n", + "print(\"ten rupee notes\",t)\n", + "h=w//100\n", + "r=w-(100*h)\n", + "f=r//50\n", + "r=r-(50*f)\n", + "t=t//10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "default_view": {}, + "name": "Lab1 Notebook.ipynb", + "provenance": [], + "version": "0.3.2", + "views": {} + }, + "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.6.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}