Advertisements
Advertisements
Write the definition of a Python function named LongLines() which reads the contents of a text file named 'LINES.TXT' and displays those lines from the file which have at least 10 words in it. For example, if the content of 'LINES.TXT' is as follows:
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf.
Then the function should display output as:
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.
Concept: Reading from a Text File in Python
Write a function count_Dwords() in Python to count the words ending with a digit in a text file "Details.txt".
Example:
If the file content is as follows:
On seat2 V1P1 will sit and
On seat1 VVIP2 will be sitting
The output will be:
The number of words ending with a digit is 4
Concept: Reading from a Text File in Python
Write one difference between CSV and text files.
Concept: Types of Files in Python
Which of the following functions changes the position of file pointer and returns its new position?
Concept: Setting Offsets in a File in python
Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the tuple will have (4, 3, 2, 4, 4, 3)
Concept: Reading from a Text File in Python
Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with the word ‘You’.
Concept: Reading from a Text File in Python
Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.
Concept: Reading from a Text File in Python
Consider a file, SPORT.DAT, containing records of the following structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the records with Sport name as “Basket Ball” to the file named BASKET.DAT. The function should return the total number of records copied to the file BASKET.DAT.
Concept: The Pickle Module in Python
A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
- MNO - Movie Number
- MNAME - Movie Name
- MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.
Concept: The Pickle Module in Python
How are text files different from binary files?
Concept: Types of Files in Python
Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.
Concept: Keys in a Relational Database
Explain the concept of “Alternate Key” in a Relational Database Management System with an appropriate example.
Concept: Keys in a Relational Database
The school has asked their estate manager Mr Rahul to maintain the data of all the labs in a table LAB. Rahul has created a table and entered data from 5 labs.
| LAB NO | LAB_NAME | INCNCHARGE | CAPACITY | FLOOR |
| L001 | CHEMISTRY | Daisy | 20 | I |
| L002 | BIOLOGY | Venky | 20 | II |
| L003 | MATH | Preeti | 15 | I |
| L004 | LANGUAGE | Daisy | 36 | III |
| L005 | COMPUTER | Mary | 37 | II |
Based on the data given above answer the following questions:
(i) Identify the columns which can be considered as Candidate keys.
(ii) Write the degree and cardinality of the table.
(iii) Write the statements to:
(a) Insert a new row with appropriate data.
(b) Increase the capacity of all the labs by 10 students which are on
the 'I' Floor.
OR
(iii) Write the statements to:
(a) Add a constraints PRIMARY KEY to the column LABNO in the table.
(b) Delete the table LAB.
Concept: Keys in a Relational Database
Which of the following statements is FALSE about keys in a relational database?
Concept: Keys in a Relational Database
Give one difference between alternate key and candidate key.
Concept: Keys in a Relational Database
______ command is used to remove the primary key from a table in SQL.
Concept: SQL for Data Definition
Which of the following commands will delete the table from the MYSQL database?
Concept: SQL for Data Definition
______ is a non-key attribute, whose values are derived from the primary key of some other table.
Concept: SQL for Data Definition
Which function is used to display the total number of records from a table in a database?
Concept: Functions in SQL
To establish a connection between Python and SQL databases, connect() is used. Which of the following arguments may not necessarily be given while calling connect()?
Concept: SQL for Data Definition
