Ips4 (Cse)
Ips4 (Cse)
Exercise 1:
Question:
A dealer had Rs. 'X'. He purchased 'n' number of television sets, each
costing Rs 'Y'. He used the remaining amount of money to purchase 'm'
number of washing machines. Draw a PAC and write a Python code to
determine the cost of each washing machine? For example, if the dealer
had 25,000 in hand and he bought 2 television sets each of cost Rs. 6125
and if he bought 3 washing machines then the cost of one washing
machine is 4250. Mention the cost of one washing machine in 3 decimal
places.
Problem analysis chart:
Output:
Exercise 2:
Question:
Ram buys a sweet box with 'T' sweets in it and distributes it to his
two children. He distributes 'X' percentage of the sweets given to
his son and he gets 'N' number of sweets. Write an algorithm to
determine the number of sweets got by his daughter and total
number of sweets. For example, if Ram distributes 60% to his son
and he gets 12 sweets then his daughter will get 8 sweets and there
are 20 sweets in the box.
Algorithm:
1. Start
2. Input x and n1
3. Calculate total sweets t= ((n1*100)/x)
4. Calculate number of sweets for daughter n2= t-n1
5. Display t and n1
6. Stop
Python Code:
Output:
Exercise 3:
Question:
Write a program to detect the winning tickets in the lottery game. If
the opposite order of the ticket number is the same as the original
order of the ticket number, then the ticket is considered as the
winning ticket.
Python Code:
Output:
Exercise 4:
Question:
Write a python program to print pascal’s triangle
Python Code:
Output:
Exercise 5:
Question:
Output:
Exercise 6:
Question:
Write a python script to print hollow diamond pattern
Python Code:
Output:
Exercise 7:
Question:
Write a program to display Fibonacci series
Python Code:
Output:
Exercise 8:
Question:
In an orphanage there were about 5 to 7 babies in the age group of
2months to 1 year. The founder of the orphanage wanted to name all
these babies with special names. The names were special since all
the names to be selected are palindromes. The founder’s friend gave
him a list of baby names with serial numbers in sequence. The
founder needs to select the palindrome names out of the list. Help
the founder by implementing a python code in identifying the
palindrome names out of the list along with corresponding serial
number. Also, your program needs to count the number of
palindrome names present in the list. If there is no palindrome string
print 0.
Python Code:
Output:
Exercise 9:
Question:
Create a program to store your entire friend’s name list. Display the
number of friends you have. Also display your friend's name who
possess the longest name (maximum length) along with the number of
characters in that name. For example, if the names of the friends are
Ravi, Raj and Puela then the output is 3, Puela and 5.
Python Code:
Output:
Exercise 10:
Question:
Devise a flowchart/algorithm and write the Python code to
count the number of each vowel in a given text. For example, if
the text 'Hi How are you' then the Python code must print letter
'a' followed by number of times 'a' has occurred and so on.
Algorithm:
1. Start
2. Input a sentence s
3. Declare variable l and set its value as length of the sentence
4. Declare a, e, i, o and u as 0
5. Make an if else construct in a for loop to count frequency of
vowels and assign them to the corresponding variables
6. Print frequency
7. Stop
Python Code:
Output:
Exercise 11:
Question:
Mr. Raju has some money and he gives it to his two children in
the ratio a: b. Given the amount that Raju has and the values of a
and b, determine the amount that will be received by his children.
Round off the resultant money that is Rs. 101.2 is Rs.101, Rs.
101.5 is Rs. 102. For example, if Raju has Rs. 2500 and he give to
his children in ratio 3:4, then the first child will get Rs. 1072 and
the second child will get Rs.1428.
Python Code:
Output:
Exercise 12:
Question:
A person from USA wants to know his Body Mass Index (BMI).
He knows his weight in pounds and height in inches. The evaluator
knows the formula for calculating BMI using the formula,
BMI = (weight in kilograms) / (height in m * height in m)
Help the person in finding his BMI by writing a program for him.
(Use the conversion formulae: 1 pound =0.4536 kilograms, 1 inch =
2.54 cms)
Python Code:
Output:
Inference:
Understood the various concepts covered in modules 1, 2 and 3 by
solving and understanding the applications of various programs.