Professional Documents
Culture Documents
Labs_solved
Labs_solved
Labs_solved
Output:
Output:
7. Write a program to print this patterns
*
* *
* * *
* * * *
Output:
2. Write a python program to swap two numbers without using third variable
Code:
Output:
3. Write a python program to read two numbers and find the sum of their cubes
Code:
Output:
4. Write a python program to read three numbers and if any two variables are
equal, print that number
Code:
Output:
5. Write a python program to read three numbers and find the smallest among
them
Code:
Output:
6. Write a python program to read three numbers and print them in ascending
order (without using sort function)
Code:
Output:
7. Write a python program to read radius of a circle and print the area
Code :
Output:
8. Write a python program to read a number ,if it is an even number , print the
square of that number and if it is odd number print cube of that number.
Code:
Output:
Name: Mohd Adnan Zohaib
Roll. No,: 2K22CSUN01149
Subject Name: Programming for Problem Solving using Python
Subject Code: (CSW208B)
Lab 4
Output:
2. WAP to demonstrate built in functions of Strings(rtrip, lstrip,lower, split)
Code:
Output:
\
Output:
4. WAP to capitalize the first and last character of each word in a string.
Code:
Output:
5. WAP to accept two strings from the user and display the common
words.
Code:
Output:
6. WAP to accept a string and count the frequency of each vowel. Code:
Output:
7. WAP to display the smallest word from the string.
Code:
Output:
Name : Mohd Adnan Zohaib
Course: B.Tech(CSE)
Subject: Programming for Problem Solving using Python(CSW208B)
Output:
2. Print 1st 5 even numbers (use break statement).
Code:
Output:
Output:
4. WAP to demonstrate Pass statements.
Code:
Output:
5. Write a Python program to calculate the length of a string.
Code:
Ouput:
Code:
Output:
7. Write a Python program to get a string made of the first 2 and the
last 2 chars from a given a string. If the string length is less than 2,
return instead of the empty string.
Code:
Output:
10.Write a Python program to add 'ing' at the end of a given string (length
should be at least 3). If the given string already ends with 'ing' then add 'ly'
instead. If the string length of the given string is less than 3, leave it
unchanged.
Code:
Output:
Name: Mohd Adnan Zohaib
Lab 7
Blooms Taxonomy Level: BT1, BT2, BT3
Tuple
1. Write a Python program to create a tuple.
Code:
Output:
Output
3. Write a Python program to create a tuple with numbers and print one
item.
Code:
Output:
Code:
Output:
7. Write a Python program to get the 4th element and 4th element from last
of a tuple
Code:
Output:
Output:
List
1. Write a Python program to sum all the items in a list.
Code:
Output:
Output:
4. Write a Python program to get the smallest number from a list.
Code:
Output:
5. Write a Python program to count the number of strings where the string
length is 2 or more and the first and last character are same from a given list
of strings
Sample List : ['abc', 'xyz', 'aba', '1221']
Expected Result : 2
Code:
Output:
6. Write a Python program to get a list, sorted in increasing order by the last
element in each tuple from a given list of non-empty tuples.
Sample List : [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Code:
Expected Result : [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
Output:
7. Write a Python program to remove duplicates from a list.
Code:
Output:
Output:
10. Write a Python program to find the list of words that are longer
than n from a given list of words.
Code:
Output:
11. Write a Python function that takes two lists and returns True if
they have at least one common member.
Code:
Output:
Output:
Output:
Output:
Output:
Output:
9. Write a Python class to reverse a string word by word.
Code:
Output:
Name: Mohd Adnan Zohaib
Course: B.Tech(CSE)
Subject: Programming for Problem Solving using Python(CSW208B)
Output:
2. Write a Python program to create a class Employee. Define two
subclasses: Engineer and Manager. Every class should have
method named printDesignation() that prints Engineer for Engineer
class and Manager for Manager Class.
Code:
Output:
Output:
Name : Mohd Adnan Zohaib
Course: B.Tech(CSE)
Subject: Programming for Problem Solving using Python(CSW208B)
Code:
:
Output:
Code:
Output:
Code:
Output:
4. Write a Python program to read a file line by line store it
into an array.
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Code:
Output:
Name : Mohd Adnan Zohaib
Course: B.Tech(CSE)
Subject: Programming for Problem Solving using Python(CSW208B)
Output:
9. Create a DataFrame using the following:
a. Empty DataFrame
b. DataFrame using list
c. DataFrame using dictionary
d. DataFrame using series
Code:
Output:
10. Create 3-4 four colums in a DataFrame for Q4 b-d points
11. Add index to all the rows in Q5
12. Display all the values from the DataFrame mentioned in Q6
using index and index name for :
a. Second row values
b. Second column values
13. Perform slicing by displaying 3rd and 4th row on the
DataFrame
14. Delete a row
15. Delete a column