Class 12 Computer Science-Updated
Class 12 Computer Science-Updated
Output:
Output:
Program 4: Write a Program to find factorial of the entered
number.
Output:
Output:
Program 8: Read a file line by line and print it.
Assume we have the following file, located in the same folder as Python:
Output:
Program 9: Remove all the lines that contain the character
“a” in a file and write it into another file.
Assume we have the following file, located in the same folder as Python:
Output:
Program 10: Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the
file.
Actual text file
Output:
Program 11: Create a binary file with name and roll no.
Search for a given roll number and display the name, if not
found display appropriate message.
Output:
Program 12: Write a random number generator that
generates random numbers between 1 and 6(simulates a
dice)
Output:
a=fh.readline()
words=a.split()
for j in words:
item.append(j)
if a =="":
break
print("#".join(item))
Output:
#Describing table
mysql> desc student;
+-----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| ROLLNO | int | NO | PRI | NULL | |
| NAME | char(10) | YES | | NULL | |
| TELUGU | char(10) | YES | | NULL | |
| HINDI | char(10) | YES | | NULL | |
| MATHS | char(10) | YES | | NULL | |
| Computers | char(10) | YES | | NULL | |
+-----------+----------+------+-----+---------+-------+
6 rows in set (0.21 sec)
#Droping a attribute
mysql> alter table student
-> drop column computers;
Query OK, 0 rows affected (0.93 sec)
Records: 0 Duplicates: 0 Warnings: 0
#Describing table
mysql> desc student;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| ROLLNO | int | NO | PRI | NULL | |
| NAME | char(10) | YES | | NULL | |
| TELUGU | char(10) | YES | | NULL | |
| HINDI | char(10) | YES | | NULL | |
| MATHS | char(10) | YES | | NULL | |
+--------+----------+------+-----+---------+-------+
5 rows in set (0.14 sec)
#ORDER BY BRANCH
#ACTUAL DATA
mysql> SELECT *FROM STUDENT;
+--------+--------+----------+--------+-------+-------+
| ROLLNO | BRANCH | NAME | TELUGU | HINDI | MATHS |
+--------+--------+----------+--------+-------+-------+
| 102 | MPC | student2 | 60 | 61 | 62 |
| 103 | BIPC | student3 | 70 | 71 | 72 |
| 104 | BIPC | student4 | 80 | 81 | 82 |
| 105 | BIPC | student5 | 90 | 91 | 92 |
| 106 | BIPC | student6 | 40 | 41 | 42 |
| 107 | MPC | student7 | 63 | 64 | 65 |
+--------+--------+----------+--------+-------+-------+
6 rows in set (0.00 sec)