{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Q1 : Write a python program to print the square of all numbers from 0 to 10." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q2 : Suppose we have a list of integers\n", "> `numbers = [1, 2, 3, 4, 5, 6]`\n", "- How to add 5 to each number?\n", "- What if we want to add 5 to only the second to the fifth number?\n", "- What if we want to add 5 to numbers with only even-numbers?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "numbers = [1, 2, 3, 4, 5, 6]\n", "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q3 : Write a Python program that accepts a word from the user and reverse it." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q : Write a program to reverse a given integer number." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q4 : There are two lists - first contains students' names and second list contains their corresponding marks.\n", "> `students = [\"Kevin\", \"Zara\", \"Tom\", \"Chris\", \"Pritam\", \"Mike\"]`\n", "\n", "> `scores = [80, 76, 92, 55, 81, 72]`\n", "- Print each student's name and his/her corresponding marks in each line." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q5 : Use a for loop to display elements from a given list which are present at even positions." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n", "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q6: Write a Python program which takes two digits m (row) and n (column) as input and generates a two-dimensional array. The element value in the i-th row and j-th column of the array should be `i*j`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q7 : Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number's digits." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q8 : Write an interactive program that takes a number from user to calculate factorial of that number.ΒΆ" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# n! = n * (n - 1) * (n - 2) * .......* 3 * 2 * 1\n", "# 0! = 1! = 1\n", "\n", "### START CODE HERE ###\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Using a while loop" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Using recursive function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Q9 : Write a program that takes an integer n as argument and return the n-th Fibonacci term. If n is negative then the function should return nothing.\n", "\n", "\n", "\n", "" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "### START CODE HERE ###\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Using recursive function" ] } ], "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 }