The questions below are extracted from previous years question paper of KTU university and are categorized in different sections for ease of students and teachers..
-
Write a python program to remove all vowels from a given string. [S-July17]
-
Write a program to perform the following operations on a given string. [S-July17]
- Convert all small letters in the string into capital letter.
- Find the number of occurrence of a given substring.
-
Let s = "orange" be a string . What will be the output of the following expressions. [Jan17]
- a ) s[0:4] b) s[6] c) s[-4] d) s[-3:]
- You are given a string ,for instance, "How are you".Split the string onto a " " (space) delimiter and join using a "-" (hyphen) delimiter. (Find the output of the given example will be "How-are-you").
-
Write a program to check if a given string is a palindrome without reversing the original string.[Jan17]
-
Write a program to replace a substring with a new substring in the given string. [Sept16]
-
Consider the following code snippets. [Sept16]
-
one = "This is a test!" one[2] = "u" print one
-
What error will the above code produce? Why is the error caused? Write the python code which will work around this issue and print the string "Thus a test!" as output.
-
-
Write a python code to check whether 2 strings are equal are not. [Jun16]
-
Write a python code for reversing the string and print whether it is palindrome or not. [Jun16]
-
Let fruit=' apples' be a string. What will be the output of the following expressions. [Jan16]
- a) len(s1) b) s1[0:4] c) s1[6] d) s1[-4]
-
Write a Python program to count number of vowels, consonants, words and question marks in a given string. [Jan16]
-
Suppose S = "Marry had a little lamb". Write the python code to [Dec17]
- Replace "lamb" with "kid"
- Find starting index of substring "had" in the string S.
-
Write the python program to input a sentence and find the number of words in the sentence and print each word in uppercase. Also print the number of question marks (?), periods(.) and commas(,) present in the string. [Dec17]
- Write a program to sort a list of names in alphabetical order and print the sorted list in uppercase. [S-July17]
- Write a python code to find transpose of a matrix using list. [Jan17]
- What are different ways in which we can delete an item from a list? Explain with examples. [Sept16]
- Write a python code to search a element in a list. [Jun16]
- Write a python code to add 2 matrices using list. [Jun16]
- Let Data represent the list
['circle' ,'square' ,'triangle']. Write the expressions for following operations. [Jan16] - Write a Python program to input a list of n numbers. Calculate and display the average of numbers. Also display the cube of each value in the list. [Jan16]
- Define List and how can we access the elements of a list in python. [Model15]
- Let
data = [23,56,67,2,[6,7,12],123].Write the expression for following operations in Python: [Dec17]- Replace the value 67 with 89
- Print the value 12
- Remove the value 56 from list
- What are the operations associated with a list? Explain with examples. [Dec17]
- Write a Python program to input a list of numbers. Calculate and display the sum of cubes of each value in the list. [Dec17]
- Is the compound type tuple in python is mutable? Write a python script to interchange 2 variable using tuple. [S-July17]
- Compare tuple and list on basis of mutability. Give example to illustrate this. [Jan17] [Model15]
- Let
t = ('a','b','c',1,2,3). Write a python code to print the values in reverse order. - What is the difference between a list and a tuple? [Dec17]
-
How to create a dictionary for python? Write a python program to read and display a sparse matrix using dictionary. [S-July17]
-
Let student = {'John':50, 'Tom' :60, 'Nina':82} be a dictionary. Discuss the output obtained after executing the following statement. [Jan17]
newstudent = student newstudent['Tom'] = 45 print newstudent print student
-
Write a python program to create a dictionary of phone number & names of person. Display the contents of dictionary in alphabetical order of names. [Jan17]
-
Create a dictionary named 'stock'. Add the following elements to stock and perform the following operations. [Sept16]
pencil - 400, pen - 1000, eraser- 200, ink -50- Print stock.
- Delete ink and print stack.
- Explain keys and key-value pairs. Find the number of key-value pairs and identify the keys.
-
Assume variable data refers to dictionary
{"b" : 34, "a" : 67}. Write the expression not perform with following tasks. [Sept16]- Replace the value at key "b" negation of value.
- Add key:value pair "c":56 to data
- Remove the value at key "a" in data
-
Describe dictionary methods with examples. [Jun16]
-
Let farm=
{'Sheep':5,'Cows':2,'Goats':10}be a dictionary. Write the statements for following operations. [Jan16]- To add the key value pair ('Ducks':8) .
- To display the number of items in the dictionary.
- To remove the key value pair ('Cows':2)
-
Write a Python program to create a dictionary of roll numbers and names of 5 students. Display the contents of dictionary in alphabetical order of names. [Jan16]
-
With suitable examples, explain in detail about Dictionary type in python. [Model15]
-
How can you create a fresh copy of a dictionary? Explain with example. [Dec17]
-
Explain the data structure, dictionary in Python using an example. how does the dictionary operations - "del", "len", "keys", "items" and "has_key" operations work. Explain with examples. [Dec17]
This notes are written by Abhijith Sheheer , S1 C.S.E student in Vidya Academy of Science and Technology. The application used here Typora.
Made with ❤️ and Markdown