Algorithmic Thinking with python-Assignment 1
Algorithmic Thinking with python-Assignment 1
2. If the three sides of a triangle are input, write an algorithm to check whether the triangle is isosceles,
equilateral, or scalene.
3. Write a switch statement that will examine the value of flag and print one of the following messages,
based on the value assigned to the flag.
(a) to display all odd numbers between 1 and 500 in descending order.
(b) to compute and display the sum of all integers that are divisible by 6 but not by 4 and that lie
between 0 and 100.
(c) to read a value, and do the following: If the number is even, halve it; if it’s odd, multiply by 3 and add
1.
5.You visit a shop to buy a new mobile. In connection with the festive season, the shop offers a 10%
discount on all mobiles. In addition, the shop also gives a flat exchange price of Rs.1000/- for old
mobiles. Write a pseudocode and draw a flowchart to input the original price of the mobile and print its
selling price. Note that all customers may not have an old mobile for exchange.
6. Write an algorithm that inputs two values a and b and that finds ab . Use the fact that a b is
multiplying a with itself b times.
7. Draw flowcharts for the following:
(b) to find the profit or loss incurred by getting the cost price and selling price of an item. Note that you
are not asked to determine whether profit or loss is incurred but rather the value of profit or loss.
Assume cost price ̸= selling price.
(c) to find the average of a list of numbers entered by the user. The user will stop the input by giving the
value −999.
Python Programs
1. Write a Python program to calculate simple interest by inputting the value of the Principal amount,
period, and interest rate from the user.
2. Write a Python program to convert the time input in minutes to hours and minutes. For example, 85
minutes is 1 hour 25 minutes.
3. Write a Python program that inputs the cost of an item and the number of items and displays the
total cost.
4. Write a Python program that takes an amount in dollars and converts it to Indian rupees.
6. You are given the task of calculating the electricity bill of a house. Each house has the following
components: fan, light, washing machine, and computer. Each fan consumes 1 unit per day, and each
light consumes 0.5 units per day, the washing machine consumes 2 units per day and each computer
consumes 3 units per day. Let the cost of 1 unit be 50 rupees. Input the number of fans, lights, washing
machines, and computers for a particular house and find the total electricity bill for that house for 2
months. Assume a 30-day month.
7. Recall from your Chemistry classes that aqueous solutions with a pH value less than 7 are acidic,
solutions with a pH value greater than 7 are basic and those with pH equal to 7 are neutral. Write an
algorithm to determine whether a solution is acidic, basic, or neutral given its pH value.
8. The Population of a town today is 1,00,000. The population has increased steadily at the rate of 10
percent per year for the last 10 years. Write a program to determine the population at the end of each
year in the last decade.
9. Write a program to display alternate prime numbers till N (obtain N from the user).
10. Write a program for a number guessing game. The user must have only limited attempts at guessing
the number, and for every guess, a hint can be provided to the user. For example, if the user guesses 40,
the program can give a hint to make the next guess higher or lower based on the correct answer.
11. Write a program to compute and display the sum of all integers that are divisible by 6 but not by 4,
and that lie below a user-given upper limit.
12. Calculate the sum of the digits of each number within a specified range (from 1 to a user-defined
upper limit). Print the sum only if it is prime.
13. A number is input through the keyboard. Write a program to determine if it’s palindromic.
15.Write a python program to find the GCD (Greatest Common Divisor)of two numbers