Tuesday 20 September 2022

ch-5 pg 5.48

 Q22)

import math

x=int(input("enter x"))

n=int(input("Enter n"))

s=0

y=4

for i in range(2,n+1):

    if not i%2:

      s-=math.pow(x,i)/math.factorial(y)

    else:

      s+=math.pow(x,i)/math.factorial(y)

    y+=2

    

print("Sum is ",1-s)    

enter x2


Enter n3

Sum is  1.1555555555555554


Q23)

n=int(input("Enter n"))

s=0

for i in range(1,n+1):

    for i in range(1,i+1):

        s+=i

    

print("Sum is ",s)    


Enter n3

Sum is  10


ch-3 Computational Thinking and Getting Started with Python

 Pg 3.30 Unsolved Qns

1)  In order to solve a problem, some thought process is required that involves computational thinking. Computational thinking means any method that is adopted to solve a given problem based on some inputs. This requires some skills like breaking down the problem into smaller units,showing only essential details and hiding background details , recognizing pattern across all similar problems and deriving an algorithm for the problem.

2) Writing functions - Decomposition

     Writing classes - Abstraction

     Looping constructs and expressions - Pattern Recognition

     Psuedocode / Algorithm - leading to python program

3) Python is easily downloadable and the source code also is available along with the software.

4) It is not structured like C++ or other object oriented languages.

    Not much emphasis on the OOPS features 

5) script mode allows us to save the files which contain the code.

    Interactive mode is the shell mode which allows us to execute code snippets without saving it as a file.

6) Decomposition - Functions

7) To use all the four components - Decomposition, Abstraction, Pattern Recognition and Algorithm.

Q8-18 - NA

19) When a large problem is broken down into units of smaller size, it is possible to comprehend and understand smaller units individually rather than tyring to undertand the entire problem.

20) Planning is very important because the program should be robust, i.e. should be able to run with any kind of data, and should deliver the output considering the time complexity factors.For this planning is required as to what language to use, how many variables to use, where to store data, what constructs to use etc.

21-NA

22) Elipse - Start/stop of process

      parallelogram - data

     rectangle- process step

    diamond - decision - making

   arrow - flow of control

23 - 26 - NA

27) Integrated Development Learning Environment

28) Displaying is echoing on the screen in the shell window, the value of the variables.

Printing is printing the values, based on the print statement.

29) a) Interpreted and compiled code

     b) free open source software

     c) Easily portable

     d) Compatible with other languages

     e) case sensitive

     f) supports GUI

     g) Platform independent

30-36 - NA

37-39 - Already discussed