CLASS XIIA ONLINE CLASSES BY R.K.YADAV PGT-CS

                                                  PYTHON LEARNING BY RK YADAV KV RDSO LUCKNOW:-
BE SAFE STAY HOME FROM CORONA VIRUS (COVID-19) 
TODAY CLASS AS ON  :- 06-05-2020
JUST OPEN LINK FOR NOTES Python Library
PDF LINK FOR 06-05-2020
PDF LINK FOR 30-04-2020 CLASS
PDF LINK FOR 05-05-2020 CLASS































































Introduction:

A library is a place where lots of books, magazines, CDs, newspapers are found to read. These all books are divided into several chapters, magazines are divided into several articles
Definition:

A library is a collection of modules or functions in a python that allows to do a specific tasks to fulfill user's need. This library serves little bit similar functions as header files used in C or C++. Some commonly used python libraries are as following:
  1. Standard Library:  It provides some common standard IO operation related functions such as print(), input(), int() along with some math modules, random modules, statistic modules etc.
  2. NumPy Library:  This library is used to handle arrays to cater basic mathematical operations. Ex.: square(), absoulte(), log(), sqrt() etc.
  3. SciPY Library: This offers algorithmic and mathematical functions for scientific calculations. Ex.: io(), linalg(), interopolate() etc
  4. Matplotlib Library: This library offers functions related to graphs and charts in python. Ex.: plot(), label(), show() etc
  5. Tkinter Library: This library provides functions to design GUI based interface for different applications. Ex.: tkMessageBox(), tkColorChooser(), tkSimpleDialog() etc.
Importing python module:-To import python modules in a program import statement can be used in two ways:
    1. import <command> : import math, import numpy etc
    2. from <module> import <object>:  from math import pi, sqrt
    Note: User can import multiple objects from <module> import <object> with comma separated objects or * to import all objects
Using Mathematical Functions:

To use mathematical function import math object by using import:
import math

The following functions are most commonly used functions provided by math module:
  1. ceil():Return the smallest integer greater than or equal to the number specified.
    Ex.: >>> math.ceil(12345.6786)
    Output:12346
  2. fabs():Return the absolute value of given number. Convert and display negative number into positive number.
    Ex.: 
    >>> math.fabs(-15)
    Output:15.0
  3. factorial():Return the factorial of given number. If the number is integral or negative then it returns ValueError.
    Ex.: 
    >>> math.faactorial(5)
    Output:120
  4. floor():Return the largest integer less than or equal to the number specified.
    Ex.: 
    >>> math.floor(12345.6786)
    Output:1234
  5. fmod():Return the remainder working with float values only. For integer use % operator.
    Ex.: 
    >>> math.fmod(15.8899,4)
    Output:3.889900000000001
  6. fsum():Return addition of values in iterable.
    Ex.: 
    >>> math.fsum([1.5,2.5,3.5])
    Output:7.5
  7. gcd():Return common divisor of the specified numbers x and y.
    Ex.: 
    >>> math.gcd(42,28)
    Output:14
  8. remainder():Return remainder of integer with number x divided by y.
    Ex.: 
    >>> math.remainder(12,5)
    Output:2.0
  9. pow():Return power of x raised by y.
    Ex.: 
    >>> math.pow(5,3)
    Output:125.0
  10. sqrt():Return square root of given number.
    Ex.: 
    >>> math.sqrt(100)
    Output:10.0
Using string Functions:-
  1. To use string functions a variable needs to assign with specific string value.
    For Ex.: str ="fun with python"

    1. capitalize(): Convert first letter of the text into capital.
    2. Ex.: >>> str.capitalize()
      Output:'Fun with python'
    3. center(): It align the string to center by filling padding the character left and right of the string.
      Ex.: >>> str2=str.center(20,'*')
      Output:'**fun with python***'
    4. count():Return no. occurrences of specified string.
      Ex.: 
      >>> str.count('with',4,10)
      Output:1
    5. endswith():Return True if the specified text ends with given string, otherwise False. stratswith() method is opposite of endswith.
      Ex.: 
      >>> str.endswith('on',0,20)
      Output:True
    6. find():Return lowest index in the string where substring sub is found, such that sub is contained in the range. Returns -1 if substring is not found the text.
      Ex.: >>> str.find('with',4,10)
      Output:4
    7. isalnum():Return True if all characters in the string are alphnumerical otherwise False. It requires at least 1 character.
      Ex.: 
      >>> str='funwithpython2020'
              
      >>> str.isalnum()
      Output: True
    8. Similarly isalpha(), isdigit(), islower(), isspace(), istitle, isupper() functions return True respectively, otherwise false. 
    9. join():Concate string specified as in sequence.
      Ex.: 
      >>>str='fun with python 2020'
              >>> str.join(['hello! ',' is amazing')
      Output: 'hello! fun with python 2020 is amazing'
    10. upper(): Convert all text into capital letters. 
    11. Ex.: >>> str.upper()
      Output:'FUN WITH PYTHON 2020'
    12. title(): Convert first letter of each word into capitals. 
    13. Ex.: >>> str.title()
      Output:'Fun With Python 2020'
    14. swapcase(): Convert capital letters into small letters and small letters to capital letters.
    15. Ex.: >>> str.swapcase()
      Output:'FUN WITH PYTHON 2020'
    16. split(): Split the the words by given characters. If number is specified as maxsplit then it returns n+1 string as output.
    17. Ex.: >>> str.split(' ')
      Output:['fun','with','python','2020']
    18. ljust(): Return the string in left justified in a string of up to the length of string. The string is filled up with a specified character. rjust() is just opposite of ljust().
    19. Ex.: >>> str.ljust(25,'*')
      Output:'fun with python 2020******'
    20. lower(): Convert the specified text into lowercase. 
    21. Ex.: >>> str.lower()
      Output:'fun with python 2020
    22. lstrip(): Removes the specified characters from the string from leading text. rstrip() is just opposite of lstrip().
      1. Ex.: >>> str.lstrip('ufp')
        Output:'n with python 2020'
    23. replace(): Replace the new text with old text.
      1. Ex.: >>> str.replace('fun','play')
        Output:'play with python 2020'
























 CLASS ON  :- 28-04-2020
JUST OPEN LINK FOR NOTES





















Today class 09-04-2020


Python Functions EXAMPLE :-

  1. WRITE A FUNCTION TO PRINT SUM OF THREE SUBJECT MARKS,USE PYTHON CODE?
  2. WRITE A FUNCTION TO PRINT FIBO SERIES OF ANY NUMBER,USE PYTHON CODE ONLY ?
  3. WRITE A FUNCTION TO PRINT FACTORIAL NUMBER  USE PYTHON CODE ONLY ?
  4. WRITE A FUNCTION TO PRINT THE TABLE OF ANY GIVEN NUMBER USE PYTHON CODE?
  5. WRITE A FUNCTION TO FILTER THE LIST OF EVEN NUMBER USE PYTHON CODE ONLY ?  EXAMPLE:-
               L= [1,2,3, 4,5,6,7,8,9,10]
               RESULT
               L = [2.4.6.8.10]    
     Note :- All above do in copy as well as computer  system  .
                  You can define any function as you want ,  

Solution question no-2


def fibo(n):

    a=0

    b=1

    print(a)

    print(b)

    for i in range(0,n-1):

        c=a+b

        print(c)

        a=b

        b=c

run its output are like as

>>> 
 RESTART: C:/Users/RajKumar/AppData/Local/Programs/Python/Python37-32/fibo.py 
>>> fibo(5)
0
1
1
2
3
5
>>> 
4


Today class 08-04-2020

Python Functions:-


A function is a user define  block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

Creating a Function


In Python a function is defined using the def keyword:



Example:-

def my_function():
  print("Hello ,i am studying  class XIIA student")

  print("Have a nice day")


call the function as below.

>>>my_function()

Hello ,i am studying  class XIIA student

Have a nice day

ACTIVITY FIND OUTPUT:-
Q1:- >>>chr(65)
        >>>ord("a")
        >>>ord("a")
Q2. A= "HELLOINDIA"
       B= len(a)
       print(B)
Q3:- range(10)
        range(1,5)
        range(1,10,2)
Q4:-X= 15.12345
      print("%f,%2f"%(X,X))
Q5:-def fun(s):
          k = len(s)
          m= ""
     for i in range(0,k):
           ifs[i].upper()
                m = m +s[i].lower()
           elif s[i].lower():
                m= m+s[i].upper()
          else:
                m= m+"bb""
      print(m)
run the programe

  fun("school2@com")


BE SAFE STAY HOME FROM CORONA VIRUS (COVID-19) by TEAM KV RDSO LUCKNOW 


             

Comments

Popular posts from this blog

SAMPLE PAPER FOR CS /IP FOR CLASS XII CBSE

ONLINE CLASSES FOR XIIA COMPUTER SCIENCE NEW PYTHON 083