CBSE CLASS 12

CBSE Class 12 : Python

Revision tour

CBSE Class 12 : Functions

Functions

User defined functions

Resursion

Recursion Examples

CBSE Class 12: Inbuilt Functions

String Inbuilt Functions
Math Inbuilt Functions
Date and Time Inbuilt Functions
Random Module

CBSE Class 12 : Data File Handling

Data File Handling

Character by Character reading
Word by word reading
Line by line reading

CBSE Class 12 : Data Structures

Introduction to Data Structures
Stacks and its Applications
Implementation of Stacks
Queue and its Applications
Implementation of Queue

CBSE Class 12 : Interface Python With SQL

Class 12 Interface Python With SQL

Example : 1 Student Record management

Example :2 Bank Record Management

CBSE Class 12 : Web Development With Django

Introduction To Django

Example 1: To Test Django

Example 2: To Display Welcome Message

Example 3: To Display Data in Table Format

CBSE Class : Communication And Network Concepts

Full Forms

Computer Networks

Wired and Wireless Networks

New Technologies

Network Devices

Network Stack

IP Address

Transmission Control Protocol

Basic Network Tools and Applications

Switching techniques

 

Network topologies

Society Law and Ethics

Society Law and Ethics

Digital Property Rights

LICENSING

CYBERCRIME

Cyber Forensics

Technology And Society

Gender and Disability issues

 

CBSE Class 12 : Sample Papers

Class 12 Python Sample Paper 1
Class 12 Python Sample Paper 1 (Solution)
Class 12 Python Sample Paper 2
Class 12 Python Sample Paper 2 (Solution)

CBSE Class 12 : Practical File

Practical File Programs

CBSE Class 12 :  Python Project

Student management System

Student Management System 2

Banking System

MarkSheet Management System

Stock Management System

Telephone Directory

Digital Directory

Class XII: Examples of Recursion

Question:1

Write a python script to take input for a limit, calculate and print sum of all the numbers upto to the limit? (using recursion)

Solution:

#rec_1.py
#sum of all the numbers upto to a limit
def rec_sum(n):
    if(n==0):
        return(0)
    else:
        return(n+rec_sum(n-1))
#function calling
n=int(input("Enter limit "))
s=rec_sum(n)
print("Sum = ",s)

Question:2

Write a python script to take input for a limit, calculate and print product of all the numbers upto to the limit? (using recursion)

#rec_2.py
#prod of all the numbers upto to a limit
def rec_prod(n):
    if(n==0):
        return(1)
    else:
        return(n*rec_prod(n-1))
#function calling
n=int(input("Enter limit "))
s=rec_prod(n)
print("product = ",s)

Question:3

Write a python script to take input for a number , calculate and print its factorial? (using recursion)

#rec_3.py
#factorial of a number
def rec_fact(n):
    if(n==0):
        return(1)
    else:
        return(n*rec_fact(n-1))
#function calling
n=int(input("Enter any number "))
f=rec_fact(n)
print("Factorial = ",f)

Number Of Visitors

0270408