Download Python best notes best notes and more Summaries Computer Science in PDF only on Docsity!
1
SYLLABUS OF UNIT- 3
Python Complex data types: Using string data type and string operations, Defining list and list
slicing, Use of Tuple data type. String, List and Dictionary, Manipulations Building blocks of
python programs, string manipulation methods, List manipulation. Dictionary manipulation,
Programming using string, list and dictionary in-built functions. Python Functions, Organizing
python codes using functions.
3
…. IMPORTANT QUESTION OF UNIT- 3
- Construct a program that accepts a comma separated sequence of word as an input and prints the word in a comma- separated sequence after sorting them alphabetically.
- What is tuple. Explain the unpacking of tuple. Explain the operation applied on tuple 10 Write a python function removekth (s,k) that takes as input a string and integer k>=0 and remove the character at index k. if k is beyond the length of s, the whole of s is returned For example removekth(“python”,2) return pyhon Removekth(“mango”,1)return mngo 11 Write a python program ,count_square(N) that returns the count of perfect square less than or equal to N(N>=1) for example count_square(1) return 1 only prefect square less than equal to 1 count_square(5 ) return 2 (1, 4 are the prefect square less than equal to 2 count_square(55) return 7 (1,4,9,16,25,36,49)<=
- Explain different functional argument with example. Write a program to construct calculator using function
LIST AKTU (2022-23)
at is Stack Organization? The list is a sequence data type which is used to store the collection of data Lists in Python can be created by just placing the sequence inside the square brackets[ ].. list doesn’t need a built-in function for its creation of a list.. the list may contain mutable element list may contain duplicate values with their distinct positions
4 reverse() Reverses objects of the List in place 5 remove() Removes a given object from the List. 6 .Sort() Sort a List in ascending, descending, or user- defined order
7 pop() Removes and returns the last value from the List or the given index value. 8 insert() method inserts an item at a specific index in a list. 9 index() method searches for a given element from the start of the list and returns the position of the first occurrence_._
LIST SLICING
In order to access a range of elements in a list, you need to slice a list. One way to do this is to use the simple slicing operator i.e. colon(:). Lst[ Initial : End : IndexJump ] TO PRINT THE COMPLETE LIST PRINT ONLY 2,3,4 ,5 index element
1 Print from 4 element of the list then take jump of 2 upto the end of the list. Write a function to find ASCII value of the character. Write a program to reverse a list
lustrate different list slicing constructs for the following operations on the following list:L= [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] (AKTU 2023 - 24 ODD)
- Return a list of numbers starting from the last to second item of the list
- Return a list that start from 3 rd item to second last item.
- Return a list that has only even position elements of list L.
- Return a list that starts from the middle of the list L.
- Return a list that reverses all the elements starting from element at index 0 to middle index only and return the entire list.
- Divide each element of the list by 2 and replace it with the remainder.
lustrate different list slicing constructs for the following operations on the following list:L= [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
- Return a list of numbers starting from the last to second item of the list
- Return a list that start from 3 rd item to second last item.
- Return a list that has only even position elements of list L to list M.
- Return a list that starts from the middle of the list L.
- Return a list that reverses all the elements starting from element at index 0 to middle index only and return the entire list.
- Divide each element of the list by 2 and replace it with the remainder.
Write a function make Pairs that takes as input two lists of equal length and return a single list of same length where kth element is the pair of k element from the input list For example Make Pairs([ 1 ,, 3 , 4 , 5 ],[ 2 , 3 , 4 , 9 ]) Return[( 1 , 2 ),( 3 , 3 ),( 4 , 4 ),( 5 , 9 )] Make Pairs([],[]) Returm[] (AKTU 2020 - 21 )
Consider following filter (AKTU 2023-24 ODD) 1 filter all the numbers 2 filter all the string starting with vowels