The document contains a structured index of programming tasks related to functions, data files, stacks, and MySQL with Python. It includes specific programming questions with sample code solutions for generating series, reversing text, finding prime numbers, and SQL commands for database queries. A total of 20 programming tasks are outlined in the document.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
9 views10 pages
Cs PF
The document contains a structured index of programming tasks related to functions, data files, stacks, and MySQL with Python. It includes specific programming questions with sample code solutions for generating series, reversing text, finding prime numbers, and SQL commands for database queries. A total of 20 programming tasks are outlined in the document.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10
INDEX
S Topic No. Of Pa Date Of Sign
no Progra ge Submis ature . ms No. sion 1. Working 5 With Functions 2 Data Files 8 3 Stacks 2 4 MySQL 3 5 MySQL 2 and Python Interface Total 20 Programs
Working with Functions
Q 1. WAP that generates a series using a function which takes first and the last value of the series. And then generates four terms that are equidistant. Eg. if two numbers passed are 1 and 7 then function returns 1 3 5 7. Display the error message if equidistant numbers cannot be formed. Ans) def series(a,b): if (b-a)%3==0: d=(b-a)//3 return(a,a+d,a+2*d,b) else: print('Sorry! equidistant numbers could not be formed :( ') #_main_ a=int(input('enter the first value')) b=int(input('enter the second value')) print(series(a,b))
Q2. The function REV( ) that accept a line of text as
argument and returns the line in which each word is reversed. Display both original and reversed line of text. Ans) def REV(s): l=s.split() l2=[] for i in l: m=i[ : :-1] l2.append(m) p=' '.join(l2) return (p) #_main_ s=input('enter a sentence') print(REV(s))
Q5. The function to find and display all the prime
numbers between 2 to N, where N is passed as argument to the function. Ans) def fprime(N): def prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True p = [] for num in range(2, N + 1): if prime(num): p.append(num) print("Prime numbers between 2 and", N, "are:", p)
#_main_ N =int(input('enter a number')) fprime(N)
Q 16. Consider the following tables GAMES and PLAYER
and Write SQL commands for the flowing statements: (i) To display the name of all GAMES with their GCodes (ii) To display details of those GAMES which are having PrizeMoney more than 7000.
(iii) To display the content of the GAMES table in
ascending order of Schedule Date.
(iv) To display sum of PrizeMoney for each Type of
GAMES . Q 17. Consider the following tables Stationary and Consumer. Write SQL commands for the statement (i) to (iv) (i) To display the details of those consumers whose Address is Delhi. (ii) To display the details of Stationary whose Price is in the range of 8 to 15. (Both Value included)
(iii) To display the ConsumerName, Address from Table
Consumer, and Company and Price from table Stationary, with their corresponding matching S_ID.
(iv) To increase the Price of all stationary by 2.
Q18. Consider the following table RESORT and OWNER and Write SQL commands for the following statements: (i) to display the RCODE and PLACE of all ‘2 Star’ resorts in the alphabetical order of the place from table RESORT.
(ii) to display the maximum & minimum rent for each
type of resort from table RESORT.
(iii) to display the details of all resorts which are started
after 31-Dec-04 from table RESORT. (empty set)
(iv) to display the owner of all ‘5 Star’ resorts from tables