Lab Assignment 1 - sirisha1206/Python GitHub Wiki
Name:Naga Sirisha Sunkara
Class ID:34
Team ID:4
Technical partners details:
Name:Vinay Santhosham
Class ID:28
Introduction:
We have learnt about basic data types in python ,object oriented concepts and few modules in python
Objective:
The main objective of this lab assignment is :
Task 1:Validation of password for UMKC web application with the given criteria
Task 2:Functions that accepts the sentence from the user and displays the middle word,longest word and reverse all the words in the sentence
Task 3:Code to find triplets in the list which gives the sum of zero.
Task 4:Two lists having the students attending python class and web class.Task is to find out the list of students attending both and list of students who are uncommon in both
Task 5:Implement inheritance,multiple inheritance and other object oriented concepts
Task 6:To create random vector of size 15 having only Integers in the range 0-20 and find out the frequent number in the vector. list
Task1:Validation of password:
The password should contain 6-16 characters,one upper case,one lower case,one special character $@!* We have used regular expression module to validate the password criteria.The user has to give the password until he enters the valid password.
Code:
Output:
Task2:functions to find the largest ,middle in the given sentence and reverse of the sentence
User has to give the input as sentence.To find out the middle word we have to count the number of words in the sentence .If the number of words are even then it has two middle words with indices i.e.,len(list)/2 -1 and len(list)/2 and if the number of words are odd then it has one middle word len(list)/2. To find out the longest word in the sentence we use max(list,key=len) function. To get the reverse of each word in the sentence we iterated through the each word and reversed the word using word[::-1] and added it to the reverse_sentence variable.
Code:
Output:
Task3:Finding the triplets in the list which gives the sum to zero
We sorted the list of numbers in ascending order and implemented the following logic to find the triplets.
Code:
Output:
Task4:Finding the items common in both the lists and uncommon in 2 lists
We have taken the items in the lists from the user separated by space and split them with space. We found the intersection of 2 lists using & operator by converting them to sets. We found the uncommon items of 2 lists using symmetric_difference() by converting them to sets.
Code:
Output:
Task5:Implenting object oriented programming concepts by implementing library management system
We have created 5 classes Person,Student,Librarian,Book,BookBorrow.Person is the base class ,Student and Librarian are inherited from Person Class and BookBorrow is inherited from Student and Book classes.We used private data member to __count the number of persons.
Code:
Output:
Task6:Generating the random vector of size 15 between 0-20 and finding the most frequent number in the vector
To perform this task we used numpy module and generated a random vector using random function.(np.random.randint(20,size=15)). To find the frequent number in the vector we used np.bincount(ranVector).argmax() function.
Code:
Output:
Conclusion: Implemented all the tasks given .
References: https://www.stackoverflow.com https://www.geeksforgeeks.com