Lab Assignment 1 - VineethaG/Python_CS5590 GitHub Wiki

Python Lab Assignment-1

Team ID: 12
Team Member 1: Vineetha Gummadi, Class ID: 10,
Team Member 2: Amulya K, Class ID: 14

Task 1: Password validation for Web Application login: Following are the criteria for valid password a. The password length should be in range 6-16 characters b. Should have at least one number c. Should have at least one special character in [$@!*] d. Should have at least one lowercase and at least one uppercase character

Code Snippet:

Loops until the valid password is entered on given conditions

Output:


Task 2: Write a Python function that accepts a sentence of words from user and display the following:

a. Middle word b. Longest word in the sentence c. Reverse all the words in sentence

Code Snippet:

Middle Words:Depending on the number of words in a sentence it prints the middle words. If the sentence has even number of words (by calculating length%2 ) it prints the 2 middle words and for odd length it one middle word.

Longest Word: Calculates length of each word and gives the maximum length value

Reversing words: Reverses each word in a list and joins all the words and converted into lower case

Output:

Task 3: Given a list of n number, write a Python program to find triplets in the list which gives the sum of zero.

Code Snippet:

Takes the input list from the user. Defines the empty list ‘triplets’. Takes the first number from the list and loops in range of length of list. And then takes the second number from the list and 3rd number is selected if the sum of 3 becomes zero and print that triplet.



Output:

Task 4: Consider the following scenario. You have a list of students who are attending class "Python" and another list of students who are attending class "Web Application". Find the list of students who are attending both the classes. Also find the list of students who are not common in both the classes. Print the both lists.

Code Snippet:

Python_class|web_class –> to find the union of the 2 sets

Python_class^web_class –> to find the non-common values in both the sets


Output:

Task 5: Hotel Reservation System (e.g. classes Room, Occupants, Employee etc.)

Occupant class to customer details who would like to reserve a room. Calculates the price depending on the type of room, number of rooms, number of people

Code snippets:





Task 6: Using NumPy create random vector of size 15 having only Integers in the range 0-20. Write a program to find the most frequent item/value in the vector list.

bincount is used to count the number of occurrences of each value in array. Argmax is used to return the maximum

Output:

⚠️ **GitHub.com Fallback** ⚠️