Posts

Assignment

Image
  Programming in Python CST 362  Assignment -1 Date of submission:3-Feb-2025   before 1:30pm Note: Create a pdf file with program and output. Submit the printout control statements (if , for , while ) 1. Print the sin series x-x^3/3!+x^5/5!....x^n/n! ( read n.) 2. In the above program read the value x and find the sum of the series.(Use factorial function from math) 3.Print the following patterns * * * * * * * * * * 1 1 2 1 2 3 1 2 3 4 The pyramid is given for n=4 do this for any n 4. Find the position of the largest digit in a number.( consider unique digits) Eg: i/p : 546 largest digit=6 position =3 5.Positive integer is called an Armstrong number of order n if abcd….x= a^n + b^n + c^n + d^n + …+x^n where n is the length of the number Eg: 153 = 1^3 + 5^3+ 3^3 #153 is an Armstrong Number. Eg:1634= 1^4+6^4+3^4+4^4#1634 is an Armstrong Number. Write a Python program to check whether the given number is an Armstrong Number. 6. Find t...

Assignment -Lists

Learning Objective: Learn Lists and List operations Program to read list of names and sort the list in alphabetical order. Program to find the sum of all even numbers in a group of n numbers entered by the user. Program to read a string and remove the given words from the string. Find the average word length of a sentence Program to read list of numbers and find the median Read list of numbers and find the standard deviation . ( #We can find median by sorting the list and then take the middle element. If the list contains even number of elements take the average of the two middle elements. squre root of variance is the standard deviation) Finding the mode of list of numbers(A number that appears most often is the mode. Program to remove all duplicate elements from a list Consider a list consisting of integers, floating point numbers and strings. Separate them into different lists depending on the data Write a Python program to read list of positive integers and separate the prime and c...

Interfaces in Python

An abstract class and interface appear similar in Python. The only difference in two is that the abstract class may have some non-abstract methods, while all methods in interface must be abstract, and the implementing class must override all the abstract methods. Rules for implementing Python Interfaces We need to consider the following points while creating and implementing interfaces in Python  Methods defined inside an interface must be abstract. Creating object of an interface is not allowed. A class implementing an interface needs to define all the methods of that interface. In case, a class is not implementing all the methods defined inside the interface, the class must be declared abstract. Ways to implement Interfaces in Python We can create and implement interfaces in two ways − Formal Interface Informal Interface Formal Interface Formal interfaces in Python are implemented using abstract base class (ABC). To use this class, you need to import it from the abc module. Examp...