Monday, 5 July 2021

WHY Software Developer ?

 


#2 Interesting Facts On PYTHON !!

 


# 1 Interesting Facts Of PYTHON !!

 


Solved Assignments Class 11 Ch-3

 

CLASS -11  COMPUTER SCIENCE

               CHAPTER- 3  DATA  HANDLING 


Assignments 

Type -A  Questions :

1. What are data types ? How are they important ?
Ans . Data types refer to different types of data that can be used in python language . 
They are important because they can be considered as backbone of programming as without them we will not be able to give single command in python.

2 . How many integer types are supported in python ? Name them .
Ans . There are 2 types of integers i.e. 
            --> Integers (signed)
            --> Booleans

3 . How are these numbers different from one another ?   33 , 33.0 , 33j , 33+j
Ans . 33 is an integer , 33.0 is floating number , 33j and 33+j both are complex numbers.

4 . The complex numbers have two parts : real and imaginary . In which data type are real and imaginary parts represented ?
Ans . Real and imaginary parts are represented in a complex number .

5 . How many string types does Python support ? How are they different from one another ?
Ans .  There are 2 types of strings i.e. single line string and multi line string which are supported in Python. 
Single line string is that string which is written or typed in one single line using single or double quotes while the multi line string is a type of string that are written or typed in multiple lines with the use of triple quotes.

6 . What will following code print ?
      str1=' ' ' Hell
                     o ' ' '
      str2= ' ' ' Hell\
                     o ' ' '
      print (len(str1)>len(str2))
Ans . True

7 . What are immutable and mutable data types ? List immutable and mutable types in python .
Ans . Immutable data types are those data types which cannot be changed while the mutable data types are those that can be changed after it's declaration.
Immutable data types - Tuple , strings , etc.
Mutable data types - List , Dictionaries , sets, etc.

8 . What are three internal key attributes of value variable in Python? Explain with example .
Ans . The 3 key attributes are :
          ---> The type of an object
          ---> The value of an object
          ---> The id of an object
Example :    >>>a=10
                  >>>print(a)
                  >>> 10
                  >>>print(id(a))
                  >>>30899132
Here in this the type  of an object i.e a is integer type , the value of it is 10 and the id of object a is 30899132.

9 . Is it is it true that if two objects return True for is operator they will also return true for == operator ?
Ans . No, this is not always true because the is operator uses reference point to compare but the == operator uses the value stored in a variable to compare . Thus always it might not happen that for any two variables having same value might be having same reference point.

10 . Are these values equal ? Why / why not ?
Ans . 
i) 20 and 20.0  ---> No , because one is integer while the other is float value.
ii) 20 and int(20) ---> Yes,because both these values are of integer type.
iii) str(20) and str(20.0) ---> No , because both string values are different first is '20' while second is '20.0' 
iv) 'a' and "a" ---> Yes , because they both are pf string data types and have same value i.e a although represented in two different ways.

11 . What is an atom ? What is an expression ?
Ans . An atom is something that has a value . Identifiers , literals , strings , lists, tuples , sets, dictionary , etc. are all atoms .
An expression in Python is any valid combination of operators and atoms. An expression is composed of one or more operations.

12 . What is difference between implicit type conversion and explicit type conversion ?
Ans .  An implicit type conversion is that which is done in backside of coding and is done by python compiler or interpretor while the explicit type conversion is that in which user by using some conversion functions convert the data type by its own.

13 . Two objects (say a and b) when compared using == , return true but Python  gives false when compared using is operator why ?
Ans . This might be due to different reference points to which the variables a and b might be pointing although having same value .

14 . Given str1="Hello" , what will be value of ? 
Ans . 
a) str1[0] ---> "H"
b) str[1] ---> "e"
c) str[-5] ---> "H"
d) str[-4] ---> "e"
e) str[5] ---> error

15 . If you give str1='Hello' , whiy does the below code give error then ?
str1[2]='p'
Ans . This is so because we know that in python strings are immutable data types i.e. after its declaration there value can't be changed . Due to this fact only there occurs error when we write the above code .

16 . What will the result given by following ?
Ans .   a) type(6+3) ---> Integer
          b) type(6-3) ---> Integer 
          c) type(6*3) ---> Float
          d) type(6/3) ---> Float
          e) type(6//3) ---> Float
          f) type(6%3)---> Float

17 . What are augmented assignment operators ? How are they useful ?
Ans . They are the operators which enable us to combine any two or more operators and to code them in shorthand . 
They are useful as they minimise the code .

18 . Differentiate between (555/222)*2 and (555.0/222)*2 .
Ans . Although the output of the above two commands will be same i.e. a float value but there is slight difference in the input command and it's processing . In the first command all the operands are integer while in the second command one of them i.e. 555.0 is a float value .

19 . Given three Boolean variables a, b, c as : a=False , b= True , c=False.
Evaluate the following below expressions :
Ans .    a) b and c ---> False
           b) b or c ---> True
           c) not a and b ---> True 
           d) (a and b ) or not c ---> True
           e) not b and not(a or) ----> False
           f) not((not b or not a) and c) or a --->True
   
20 . What would the following code fragments result in ? Given X=3 .
Ans .    a). 1<X ---> True
           b)   X>=4 ---> False
           c) X==3 ---> True
           d) X==3.0 --->  True
            e) 'Hello'=="Hello"  ---> True
            f)  "Hello" > "hello" ---> False
            g) 4/2==2.0 --> True
            h) 4/2==2 ---> True 
            i) X<7 and 4> 5 ---> False

21 . Write the following expression in python :
Ans .  a) ⅓b²h  = (1/3)(b*2)*h
         b) ฯ€r²h = (math.pi)(r*2)*h
         c) ⅓ฯ€r²h = (1/3)math.pi(r**2)*h
         d) d=√((x2-x1)²+(y2-y1)²) => d=math.sqrt((x2-x1)*2+(y2-y1)*2)
        e) (x-h)²+(y-k)²=r²  =>  ((x-h)*2)+((y-k)2) = (r*2)
        f) X=(-b+√(b²-4ac))/2a   => X=(-b+math.sqrt((b**2)-4*a*c))/(2*a)
        g)a³ x a⁶= a^(3+6)   => (a*3)+(a6)=a*(3+6)
        h) (a³)² = a⁶   =>  (a*3)2 = a*6
        i) a³/a² = a³–²  => (a*3)/(a2) = a*(3-2)
       j) a–² = 1/a²   =>   (a*(-2)) = 1/(a*2)

22. int('a') produces error . Why ?
Ans . Because we can't convert a string data type to integer unless it has some numeral value stored in it. 

23 . int('a') produces error but the following code having int('a') in it , does not return error . Why ?
Len('a')+2 or int('a') 
Ans . In the above expression the code is a Boolean expression thus when error occurs in int('a') it give the value as False and proceeds to the addition due to or operator. 

24 . Write expression to convert the values 17 , Len('ab') to -
Ans .    a) integer ---> by using int( ) function
           b) string ---> by using str( ) function
           c) Boolean values ---> by using bool( ) function

25 . Evaluate :
Ans . a) 22.0/7.0 - 22/7 = 0
         b) 22.0/7.0 - int(22.0/7.0) = 0
         c) 22/7 - int(22.0)/7 = 0
Each of the above code will give output --> 0 .This is so because in case a the output of both 22.0/7.0 and 22/7 gives the same output and thus their subtraction result in 0.
Similar is the case in b and c .

26 . Evaluate and justify : 
Ans . a) false and None --->   error as false is not defined
         b) 0 and None --->  0
        c) True and None ---> None
        d) None and None ---> None

27) Evaluate :
Ans .   a) 0 or None and "or" = None
           b) 1 or None and 'a' or 'b' = 1
           c) False and 23 = False
           d) 23 and False = False
           e) not(1==1 and 0!=1) = False
           f) 'abc'=='Abc' and not(2==3 or 3==4) = False
           g) (False and 1==1 or not True or 1==1 and False or 0==0) = True

28) Evaluate the following for each expression, that is successfully evaluated determine its value and type for  unsuccessful expression state the reason :
Ans . a) Len('hello')==25/5 or 20/10 --> True
          b) 3<5 or 50/(5-(3+2)) ---> True
          c) 50/(5-(3+2)) or 3<5 ---> Error due to division by 0.
          d)2*(2*(Len("O1"))) ---> 8

29) Write an expression that uses exactly 3 arithmetic operators with integer literals and produces  result as 99 .
Ans . 9/3*11+33

30) Add parentheses to the following expression  to make the order of evaluation more clear .
Ans . (y%4)==0 and ((y%100)!=0) or ((y%400)==0)

Type - B  Application Base Questions :

Ans 1 . 
a) bool(0) = False. -->  It gives the Boolean value of zero which False . (0= False and 1= True)
b) bool (str(0)) =True. --> It gives True because the str( ) function makes a string '0' and thus the Boolean value gives True.

Ans 2 .  False 

Ans 3 . This is so because we know that the division and multiplication operator always give output in float point form .

Ans 4 .   a)  3     3               b) True
                                              False

Ans 5 .  True
               False
              True
              False

Ans 6 .    -2 
                  81

Ans 7 . Error will be produced when we run this code because in the first line of code value has not been assigned to b and c .

Ans 8 .    4.6      7.4
                 13.8
                 21.0

Ans 9 .   4.0

Ans 10 .  x , y = 4 , 8 
                  z = (x / y * y ) - x
                 print ( z )

Ans 11 . Changed expression :  3  +  10/0

Ans 12 .    4       4
                    1       3

Ans 13 .    s=''12345''
                   sum=0
                  for k in s :
                       sum+= int(k)
                 print(sum)

Ans 14 .    True
                    False
                    True
                   True
                  True 
                 False

Ans 15 .  ( underlined red lines are having errors )
a)  name = ''HariT''
     print ( name )
     name [ 2 ] = ''R''
     print ( name )

b)  a = bool ( 0 )
     b =  bool ( 1 )
    print ( a==false )
   print ( b==true )

c)   print ( type ( int ( ''123'' ) ) )
     print ( type ( int ( '''Hello'' ) ) )
    print ( type ( str ( ''123.0'' ) ) )

d)   pi = 3.14
      print ( type ( pi ) )
     print ( type ( ''3.14'' ) )
    print ( type ( float ( ''3.14'' ) ) 
   print ( type ( float ( ''three point one four ' ) ) 

e)   print ( ''Hello'' + 2 )
      print ( ''Hello'' + ''2'' )
     print ( ''Hello'' * 2 ) 

f)   print ( ''Hello''  / 2)
     print ( ''Hello''  /   2 ) 
      

              

                 

Saturday, 3 July 2021

Python Course Week 1

 Python  Learning  Course  Week   #1


๐Ÿ‘‹Hi ! a very warm welcome to the beloved readers of this blog . The sole purpose of this blog is to ensure equal education granting to each and every reader despite of knowing who he/she is ? This is the Complete Python Course based on the CBSE pattern that is to be provided to readers without any money . This course will be reader-friendly as a reader can learn the language with his/her own pace and anywhere where is comfortable . 

So , in this view here this is the first week course that any learner should finish within one week so as to ensure constant and appreciable learning . This blog consists of two chapter pdf that is to be finished reading and understanding within one week . ๐Ÿ˜…Hey , Don't Worry ! No timer⏰ is there for it but the average time one might need to learn this part is one week duration thus mentioned there to ensure simple time management by reader . Although one can learn the language in his/her own pace as it is meant to be .

๐Ÿค—So , let's get started guys . Download the first week course from below ๐Ÿ‘‡

Download Lesson 1

Download Lesson 2








Friday, 2 July 2021

Solved Assignments Class 11 Ch-2

 

CLASS -11  COMPUTER SCIENCE

        CHAPTER-2  PYTHON  FUNDAMENTALS


Assignments 

Type -A  Questions :

1. What are tokens in Python ?How many types of tokens are allowed in Python ? 
Ans . The smallest individual unit in a program is known as Token or Lexical unit.
There are 5 types of tokens in Python : 1) Keywords 2) Identifiers 3) Literals 4) operators 5) Punctuators 

2. How are Keywords different from identifier ? 
Ans . An identifier is the name used to store some variable value thus it has no special meaning in a program but a keyword is a word that has some special meaning in Python and cannot be used to store some value.

3 . What are Literals ?  How many types of Literals are allowed in Python  ?
Ans . Literals are data items that have a fixed value . The types of Literals allowed in Python are - 1)String Literal. 2) Numeric Literal 3) Boolean Literal 4)Special Literal "None" 5)Literal collection

4 . Can no graphic characters be used in Python ? Give example to support your answer.
Ans . Yes , we definitely can use nongraphic characters( those characters that can't be typed directly from keyboard ) in Python . Some  of the nongraphic characters that are supported by Python are- 
\\   It does the work of a backslash 
\'    It does the work of single quotes
\"   It does the work of double quotes  , etc.

5 .How are floating constants represented in Python ? Give example .
Ans . Floating constants are of two types  1) Fractional form   2) Exponential form .
The Fractional form is represented with decimal eg.   .45 is represented as 0.45
The Exponential form is represented with the  value raised after the letter ' E '  eg . 2² will be represented as 2 E2 .

6 .How are string Literals represented and implemented in Python ? 
Ans . String Literals in Python is represented in single or double quotes . Their implementation in Python is that when we specify a string value to any variable we need to provide it in single or double quotes always . And if we want to convert any data type into string data type then we should use  string( ) function . 

7 .Which of these is not a legal Numeric type in Python ? a ) int   b ) float   c ) decimal .
Ans . c ) decimal 

8 . Which argument  of print( ) would you set for :
i ) changing the default separator (space) --> print (< to print > , end='<new separator >')

9 . What are operators ? What is their function ? Give example of some unary and binary operators .
Ans . Operators are tokens that trigger some operation on specified variables .
They are used to do some computaional operations (addition , subtraction , multiplication ,etc.) on variable .
Some of the unary operators are -
- unary plus (+)  
- unary minus (-)  
- bitwise complement (~)
- logical complement (not)
Some of the binary operators are -
- arithmetic operators ( + , - , * , etc. )
- bitwise operators ( & , ^ , | )
- shift operators ( << , >> )
- etc.

10 . What is an expression and a statement ?
Ans . An expression in any legal combination of symbols that represent certain value .
A statement is an instruction given in a program  that does some work in program .

11 . What all components can a Python program contain ? 
Ans . The various components of a Python program are - expression , statements , comments , function , block and indentation .

12 . What do you understand by block/code block/ suite in Python ?
Ans . A group of statements which are part of another statement or a function are called block/suite/block code .

13 . What is the role of indentation in Python ?
Ans . Indentations are the blank spaces that are provided before a code to create a block code .

14 . What are variables ? How are they important for a program ?
Ans . Variables are the name that stores some value in a program. They are important in a program because they are used to in almost every section of code from operating on them to printing in output .

15 . What do you understand by undefined variable in Python ?
Ans . Any variable which is not specified by any value in the program is called undefined variable in Python .

16 . What is dynamic typing feature in Python ?
Ans . Any variable pointing to a value can be made to point to some other value of different type in the same code . This facility is called dynamic typing in Python .

17 . What would the following code do : x=y=7 
Ans . This code will make the variables x and y to point to integer 7 .

18.  What is error in this code : x , y = 7
Ans . The error is that we need to provide one more value after 7 separating by ' , '. 

19 . Following code is creating some problem X=0281 . Find the problem .
Ans .  Here X=0281 will create problem because any number should not start with 0 but some other digit except it .

20 . " Comments are useful and easy way to enhance readability and understanndibility of a program . " Elaborate with examples .
Ans . Surely comments enable one to understand the code more easily . 
Example - 
a program to print the table of number 5 is as follows :
for I in range(1,11):
      print(5*I)    
                    #will print multiplication of 5and I
Here in this program the comment will acknowledge reader about the working of code and thus it becomes easy to understand the program.

Type B Application based questions :

Ans 1-  b , d , f , g ,  h

Ans 2- underlined red coloured code are wrong๐Ÿ‘‡๐Ÿป
i)   temperature=90
     print  temperature

ii)  a=30
     b=a+b
     print(a And b)

iii)  a,b,c = 2,8,9
      print(a,b,c)
      c,b,a=a,b,c
      print(a;b;c)

iv)  x=24
      4=X

v)  print(''x=" x)

vi)  else=21-5 

Ans  3-
i)   15
     13 , 22

ii)   2, 3, 6
      11, 3, 33

iii)   7, 49

Ans 4-

i)  Indentation error

ii)  String + Integer concatenation error

iii)  String Division with integer error 

Ans 5-   20 , 41

Ans 6-   10 , 20

Ans 7-   a)   12 , 6 , 24                           b)  25

Ans 8-   ''a , b , c : 10 , 20 , 30 "
              ''p , q , r : 25 , 13 , 16 "

Ans 9-    a)   value to X not provided                b)  assignment operation not allowed in print statement 
             c)   String  Division with integer error

Ans 10-   Wrong input provided i.e. String not an integer

Ans 11-   corrected code  ๐Ÿ‘‡:
               name=input(''What is your name ? '")
               print(''Hi", name , '','' ,end=''  '')
               print(''How are you doing ? '')

Ans 12-   c = int(input(''Enter your class ''))
               print('''Last year you were in class '', c-1)   

Ans 13-  a)  integer      b)  integer        c)   error           d)  string           e)   float          f)  integer
               g)  float         h)  float            i)   float

Ans 14-   a) One                                 b)  hello One

Ans 15-  a )                                         b)       Hola
                  Hola

Ans 16-  It is so because Octal data type does not have integer 8 in its any representation .

Ans 17-  4 , 6 , 8

Ans 18-   No, the id number will not be same for all values of n . It is so because the n is only a refering variable which refers to the different values assigned to it every time . 

Ans 19-  The error occurs because we are not allowed to assign value in print( ) function .

Ans 20-   The amount of seconds  93784 .

                ๐Ÿ‘‰MORE MATERIALS TO BE UPLOADED STAY TUNED๐Ÿ‘ˆ
             

Wednesday, 30 June 2021

Solved Assignments Class 11 Ch-1

 

CLASS -11  COMPUTER SCIENCE

    CHAPTER-1  GETTING STARTED WITH PYTHON


Assignments 

  • When  was  python  released  ?                                                                                      Ans. 1991

  • Who  was  python's  developer  and  which  two  languages   contributed  to it  as  a  programming  language  ?                                                                                           Ans.  Guido  Van  Russom is  the  developer  of python .                                                       The  two  languages  were :    i)  ABC language ( basic language )                                                                               ii)  Modula - 3

  • What is cross - platform software  ?                                                                              Ans . Those softwares that can run equally on variety of platforms like- Windows , Linux , Macintosh , etc.

  • What are the advantages of python programming language ?                                    Ans. Following are the benefits of using this language -                                                                       1 . Easy to use                          2. Expressive Language                                                 3 . Interpreted language         4 . It is complete in itself                                              5 . Cross- platform language    6 . Free and open source                                              7 . Variety of usage 

  • What are limitations of python programming language ?                                    Ans. Following are the disadvantages of using this language -                                                      1 . Slow language                        2. Lesser libraries than C , Java , Pearl                   3 . Not strong on type binding     4 . Not easily convertible 

  • In how many different ways can you work in python ?                                                 Ans . We can work in two ways i.e.  INTERACTIVE MODE  &  SCRIPT MODE in python .

  • What are advantages and disadvantages of working in Interactive Mode ?               Ans . Advantages :  It is very useful for testing a code and at the time of                                                    debugging .                                                                              Disadvantages  : It does not save the commands and the output comes sandwiched with  the input commands .

  •         
  • What are advantages and disadvantages of working in Script Mode ?                       Ans . Advantages :  It is very useful to save the code in the form of a program                                          and to run it later   on to get complete output .                        Disadvantages  : It is not as fast as interactive mode and is hectic to test code at the time of  debugging .                                                                                                                                                                                                                                                                                                                                                                                                                                               ๐Ÿ‘‰MORE MATERIALS TO BE UPLOADED STAY TUNED๐Ÿ‘ˆ

WHY Software Developer ?