Skip to content

Commit

Permalink
Day 10 Tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Soumayan-pal01 committed Jun 7, 2021
1 parent 958f22f commit 2030ae1
Show file tree
Hide file tree
Showing 2 changed files with 420 additions and 0 deletions.
210 changes: 210 additions & 0 deletions Tasks/DAY 10/.ipynb_checkpoints/Day10_Task_Solutions-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Day10_Task_Solutions(1929121_Soumayan)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Python Program to Check Palindrome Number. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a number: 121\n",
" Palindrome Number\n"
]
}
],
"source": [
"num1 = int(input('Enter a number: '))\n",
"num2 = num1\n",
"palin= 0\n",
"while num1 > 0 :\n",
" t = num1 % 10\n",
" palin = palin * 10 + t\n",
" num1 = num1 // 10\n",
"if palin == num2 :\n",
" print(' Palindrome Number')\n",
"else :\n",
" print('Number is not Palindrome')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Python Program to Print all multiples of 3 and 5 in an Interval."
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Start interval: 3\n",
"End interval: 100\n",
"Multiples of 3 and 5 in the interval 3 to 100 are:\n",
"15\n",
"30\n",
"45\n",
"60\n",
"75\n",
"90\n"
]
}
],
"source": [
"start = int(input('Start interval: '))\n",
"end = int(input('End interval: '))\n",
"print('Multiples of 3 and 5 in the interval {} to {} are:'.format(start,end))\n",
"for i in range(start,end):\n",
" if i % 15 == 0 :\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Python Program to Find the Factorial of a Number."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter the number: 5\n",
"5! = 120\n"
]
}
],
"source": [
"num = int(input('Enter the number: '))\n",
"n = 1\n",
"f = 1\n",
"while n <= num :\n",
" f = f * n\n",
" n = n + 1\n",
"print('{}! = '.format(num),f)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Python Program to Print the Fibonacci sequence. "
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter end value: 120\n",
"1\n",
"1\n",
"2\n",
"3\n",
"5\n",
"8\n",
"13\n",
"21\n",
"34\n",
"55\n",
"89\n"
]
}
],
"source": [
"num = int(input('Enter end value: '))\n",
"m = 1\n",
"n = 0\n",
"while m <= num :\n",
" print(m)\n",
" n, m = m, n + m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Python Program to Check Armstrong Number."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a number:153\n",
"153 is an Armstrong Number\n"
]
}
],
"source": [
"a=int(input(\"Enter a number:\"))\n",
"num=a\n",
"s=0\n",
"for i in range(num):\n",
" r = num%10\n",
" s = s+(r**3)\n",
" num = num//10\n",
"if(s==a):\n",
" print(\"{} is an Armstrong Number\".format(s))\n",
"else:\n",
" print(\"{} is not an Armstrong Number\".format(s))"
]
}
],
"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.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 2030ae1

Please sign in to comment.