Monday, July 11, 2022

Python Function - Exercise

Practice Programs:
1. Write a python function that accepts a string and calculates the number of uppercase letter and lowercase letters:
Sample String:
Hello World
Expected Output:
No. Of Uppercase Character : 2
No of Lowercase Character: 8

2. Write a calculator function that can take two or more numbers and calculate Addition, multiplication, subtraction of these number among themselves
Example: Input: 2,3,4 
Output: addition is 9, multiplication is 24 , subtraction is -5
Input: 1,2,3,4 
Output: addition is 10, multiplication is 24 , subtraction is -8

3. Write a python program that accepts a hyphen-seperated sequence of words as input and prints the words in a hyphen-seperated sequence after sorting them alphabetically.
Example Input: green-red-yellow-black-white
Expected Output: black-green-red-white-yellow

4. Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. 
Sample String : 'The Subject IS Amazing'
Expected Output :
No. of Upper case characters : 5
No. of Lower case Characters : 14

5. What will be the output of the following code?
	def my_func(var1=100, var2=200):
       var1+=10
       var2 = var2 - 10
       return var1+var2
	print(my_func(50),my_func())
    
6. What will be the output of the following code?
    value = 50
    def display(N):
       global value
       value = 25
       if N%7==0:
       	value = value + N 
       else:
       	value = value - N 
    print(value, end="#")
    display(20)
    print(value)
7. Write a python function that takes a number and calculates cube for it. The function does not return a value , if there is no value passed to the function call, the function should calculate cube of 2.

8. Write a function that takes two char arguments and return True if both the arguments are equal otherwise False
Share:

Monday, July 4, 2022

MySql Query Exercise - INBUILT FUNCTION

Emp_Details:
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+
| EMPLOYEE_ID | FIRST_NAME  | LAST_NAME   | EMAIL    |PHONE_NUMBER| HIRE_DATE  | JOB_ID     | SALARY   | COMMISSION_PCT | MANAGER_ID | DEPARTMENT_ID |
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+
|         100 | Steven      | King        | SKING    | 9436489565 | 2000-06-17 | AD_PRES    | 24000.00 |           0.00 |          0 |   		  90 |
|         101 | Neena       | Kochhar     | NKOCHHAR | 9436489365 | 1987-06-18 | AD_VP      | 17000.00 |           1.40 |        100 |            90 |
|         102 | Lex         | De Haan     | LDEHAAN  | 9436489465 | 1987-09-19 | AD_VP      | 17000.00 |           0.30 |        100 |            90 |
|         103 | Alexander   | Hunold      | AHUNOLD  | 9436489565 | 1989-06-20 | IT_PROG    |  9000.00 |           1.00 |        102 |            60 |
|         104 | Bruce       | Ernst       | BERNST   | 9436489765 | 1989-06-21 | IT_PROG    |  6000.00 |           0.00 |        103 |            60 |
|         105 | David       | Austin      | DAUSTIN  | 9436489585 | 1999-07-22 | IT_PROG    |  4800.00 |           2.50 |        103 |            60 |
|         106 | Valli       | Pataballa   | VPATABAL | 9436489565 | 1987-07-23 | IT_PROG    |  4800.00 |           0.00 |        103 |            60 |
|         107 | Diana       | Lorentz     | DLORENTZ | 9436439565 | 1999-08-24 | IT_PROG    |  4200.00 |           1.20 |        103 |            60 |
|         108 | Nancy       | Greenberg   | NGREENBE | 9436487565 | 1987-08-25 | FI_MGR     | 12000.00 |           0.00 |        101 |           100 |
|         109 | Daniel      | Faviet      | DFAVIET  | 9436488565 | 2000-06-26 | FI_ACCOUNT |  9000.00 |           4.00 |        108 |           100 |
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+

AGGREGATION FUNCTION:
Write Query for the following:
1. Write a query to list the number of jobs available in the emp_details table.
2. Write a query to get the total salaries payable to employees.
3. Write a query to get the minimum salary from emp_details table.
4. Write a query to get the maximum salary of an employee working as a Programmer.
5. Write a query to get the average salary and number of employees working the department 90.
6. Write a query to get the highest, lowest, sum, and average salary of all employees.
7. Write a query to get the number of employees with the same job.
8. Write a query to get the difference between the highest and lowest salaries.>
9. Write a query to find the manager ID and the salary of the lowest-paid employee for that manager.
10. Write a query to get the department ID and the total salary payable in each department. 
DATE FUNCTION
  1. Write a query to get the first name and hire date from emp_details table where hire date between '1987-06-01' and '1989-07-30'.
  2. Write a query to get the firstname, lastname who joined in the month of June.
  3. Write a query to get first name of employees who joined in 1989.
  4. Write a query to get department name, manager name, and salary of the manager for all managers whose experience is more than 6 years
  
TEXT FUNCTION
  1. Write a query to get the full name and hire date of the employees where the length of the first name greater than or equal to 7. 
  2. Write a query to append '@google.com' to email field.
  3. Write a query that displays the first name and the length of the first name for all employees whose name starts with the letters 'A'.
  4. Write a query display 3 character from the first name starting form  the 3rd character.
  
   
Math FUNCTION
    1. Write a query to round the commission percentage to 0 decimal place.
    
Reference: 1. www.w3resource.com
Share:

Thursday, April 14, 2022

CBSE Practical Exam

CBSE PRACTICAL EXAM

CBSE Practical Exam (083/065)- CS/IP

Practical exam is an important part of Computer Science(083)/Informatics practices(065) subject. From weightage prespectice, it hold 30 percent of total marks in CS/IP. Both CS/IP is a practical dominated subject i.e. if one is good in practical then they are in general good in the theory.

so in this article we will talk about CBSE practical exam and its components in general:

Parts of practical Exam:

  1. Pen-Paper Test
  2. Practical File
  3. Project Work
  4. Viva

The practical exam is conducted in presence of Internal Examiner(Venue School Subject Teacher), External Examiner(Subject Teacher form another school Appointed by CBSE) and an Observer(Also Appointed by CBSE).

We have article dedicated to Practical File and Project Work, Hence in this article we will only discuss Pen-Paper Test and Viva.

Pen-Paper Test:

Students during practical exam have to solve the question(coding based) on the computer and then note it down in their CBSE practical answersheet.Usually 3 hrs is given pen-paper test
The following points have to be included while answer:

  1. Question
  2. Program or Query
  3. Input/Output(if any)
  4. Documentation

Question:The question will be coding based, be it python, mysql or any other programming language. The question can SET based, randomly allocated by chit pull method. Based on the marks allocated by CBSE, one may have to attempt 3 or 4 questions. Usually it is a good practice to write the full question along with the question number in the answer script.

Program or Query:Based on the question framed in the question paper, the student needs to solve the same on the computer first, get the expected output after providing required input(if any). Once the program is constructed succesfully, it has to be properly noted down in the answer script.

Input/Output:If the program/Query takes any input value from the user then it must be noted down in the answer script. Also if the program/query generates any output, it has to noted down in the answer scripts as well.

Documentation:Documentation is a small explanation about the program, various constructs used eg loops, conditionals etc and also about the modules, functions used in the program to get the desired output from the data. It can be 4 to 5 lines long.

Example:

Question: Write a program to count the number of upper-case alphabet present in an text file ‘article,txt’.

Program:

In [ ]:
#Writing to the file
f=open("article.txt",'w')
st="An SQL JOIN clause is used to combine rows from two or more tables based on a common field between them. While querying for a join, more than one table is considered in FROM clause."
f.write(st)
f.close()

#reading from the file and counting it
f=open("article.txt",'r')
pr=f.read()
cnup=0
cnlo=0
for i in pr:
    if i.isupper():
        cnup+=1
    elif i.islower():
        cnlo+=1
f.close()
print("The number of uppercase alphabets: ",cnup)
print("The number of lowercase alphabets: ",cnlo)

Input: In this program, the text file i.e. article.txt is the input to the program and nothing else

Output:
The number of uppercase alphabets: 13
The number of lowercase alphabets: 131

Documentation:This program is used to load and process a text file. In this program we have used open() function to load and open the file in read mode. With this program we have counted the number of Uppercase letter and Lowercase letter. We have used isupper and islower function to check if the alphabet is lower case or upper case. We have also used a for loop to get access to each alphabet.

Practical File: The details about practical file can be found using this link(Click Here)

Project Work: The details about project work can be found using this link(Click Here)

Viva: In the viva question will be asked by the external examiner(appointed by CBSE). The questions will be asked from the syllabus but there is not set domain for the questions to be asked. It is a good idea to prepare questions from project and practical i.e. one should be aware of their practical and project work so that if questions are asked from that, the students will be able to answer. One should study the fundamentals of python as well.

Share: