Page 1 :
Chapter 1, Algorithms and Flowcharts, Algorithm, An algorithm is an effective method expressed as a finite list of well defined, instructions for calculating a function, starting from an initial state and initial input., Example, Let us take one simple day-to-day example by writing algorithm for making „Maggi, Noodles‟ as a food., 72, Step 1: Start, Step 2: Take pan with water, Step 3: Put pan on the burner, Step 4: Switch on the gas/burner, Step 5: Put magi and masala, Step 6: Give two minutes to boil, Step 7: Take off the pan, Step 8: Take out the magi with the help of fork/spoon, Step 9: Put the maggi on the plate and serve it, Step 10: Stop., Let`s take example for a Python program., Example, Write an algorithm to print „Good Morning‟., Step 1: Start, Step 2: Print „Good Morning‟, Step 3: Stop, #Practice for more programs…., Flowchart, In the previous section of this chapter, we have learnt to write algorithms, i.e. step-by-step, process of solving a problem. We can also show these steps in graphical form by, using some symbols. This is called flowcharting., Flowchart Symbols, Some of the standard symbols along with respective function(s) that are used for, making flowchart are as follows:, #Practice for more programs….(for infinite loop???????????), Chapter 2, Programming Methodologies, What is a Good Program?, A Good Program means that it should produce correct and faster results, taking into, account all the memory constraints., Comments, A comment is a programming language construct, which is used to embed, programmer-readable annotations in the source code of a computer program. They are generally categorized as either, „block comment‟, „line comment‟., Block comment is implemented in python by “””, and “”” and line comment is implemented by #., Example, "Write a program to print all numbers from 1 to 100 using while loop in python", A = 1, while (a<100): # While statement, print a, a = a+1, Characteristics of good programming, Flexibility- A program should be flexible enough to handle most of the changes without having to rewrite the entire program., User Friendly, A program that can be easily understood by a beginner is called „user friendly‟. It must, interact with user through understandable messages., Portability, Portability refers to the ability of an application to run on different platforms (operating, systems) with or without minimal changes., Reliability, It is the ability of a program to do its intended function accurately even if there are even, small changes in the computer system., Self-Documenting Code, The source code, which uses suitable name for the identifiers (variables and methods),, is called self-documenting code., Problem solving process, The problem solving process starts with the problem specifications and ends with a, concrete (and correct) program., Steps are:, Analyzing the problem, Decomposition, Coding, Testing and Debugging, See the error in the given example………..!!!!!!!!!!!!!!, \, See the difference…….., Chapter 3, Introduction to PYTHON, Introduction, In order to tell the computer „what you want to do‟, we write a program in a language, which computer can understand. Though there are many different programming, languages such as BASIC, Pascal, C, C++, Java, Haskell, Ruby, Python, etc., First we you must know about …, What is Compiler???, What is Interpreter???, First Step with Python, To write and run Python program, we need to have Python interpreter installed in our, computer. IDLE (GUI integrated) is the standard, most popular Python development, environment., IDLE is an acronym of Integrated Development Environment., It lets edit, run, browse and debug Python Programs from a single interface. This environment makes it easy to write programs., There are two types of modes in PYHTON:, Variables, Variables are used to store data, they take memory space based on the type of value we assigning to them. Creating variables in Python is simple, you just have write the variable name on the left side of = and the value on the right side, Every object has:, A. An Identity, - can be known using id (object), B. A type – can be checked using type (object) and, C. A value, Mutable and Immutable Variables, A mutable variable is one whose value may change in place, whereas in an immutable, variable change of value will not happen in place. Modifying an immutable variable, will rebuild the same variable., Example, >>>x=5, Will create a value 5 referenced by x, >>>y=x, This statement will make y refer to 5 of x, x=5, y=5, >>> x=x+y, As x being integer (immutable type) has been rebuild., In the statement, expression on RHS will result into value 10 and when this is assigned, to LHS (x), x will rebuild to 10. So now……, x=10 and y= 5, Datatypes-, It is a set of values, and the allowable operations on those, values. It can be one of the following:, TOKENS, A token is the smallest individual unit in a python program., LITERALS, Keywords, They are the words used by Python interpreter to recognize the structure of program., As these words have specific meaning for interpreter, they cannot be used for any other, purpose., Input (), raw_input(), Syntax of raw_input() is:, raw_input ([prompt]), Example (in interactive mode), input— x=raw_input („Enter your name: ‟), output— Enter your name: ABC, Print (), Syntax:, print(expression), Print evaluates the expression before printing it on the monitor., Example (in interactive mode), input— print(“Hello my name is Python”), output— Hello my name is Python, Chapter 4, DATA HANDLING, Data Handling. Data handling is the process of ensuring that research data is stored, archived or disposed off in a safe and secure manner during and after the conclusion of a research project., What is meant by a data type?, In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. ... This data type defines the operations that can be done on the data, the meaning of the data, and the way values of that type can be stored., Types of Datatypes:-, The main difference between primitive and non-primitive data types are: Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String ). ... A primitive type has always a value, while non-primitive types can be null ., Operators and Operands, Operators are special symbols which represent computation. They are applied on, operand(s), which can be values or variables. Same operator can behave differently on different data types. Operators when applied on operands form an expression., Chapter 4, CONDITIONALS AND LOOPS, Decision-making in a programming language is automated using conditional statements, in which Python evaluates the code to see if it meets the specified conditions. The conditions are evaluated and processed as true or false. ... If the condition is found to be false, the statement following the If condition is executed., Example. Conditional Statement: “If today is Wednesday, then yesterday was Tuesday.”, It can be classified as:-, If statement., If Else statement., Elif statement., Nested if statement., Nested if else statement., ADDING MULTIPLE CONDITIONS TO A OBJECT, EXAMPLES, Example: 1, num = 5, if(num > 10):, print(“number is greater than 10”), else:, print(“number is less than 10”), print (“This statement will always be executed” ), Output:, number is less than 10., This statement will always be executed., Example: 2, a = 7, b = 0, if (a > b):, print(“a is greater than b”), else:, print(“b is greater than a”), Output:, a is greater than b, Example: 3, a = 7, b = 0, if (a < b):, print( “a is smaller than b” ), else:, print( “b is smaller than a” ), Output:, b is smaller than a, Example: 4, passing_Score = 60, my_Score = 67, if(my_Score >= passing_Score):, print(“Congratulations! You passed the exam”), print("You are passed in the exam"), else:, print(“Sorry! You failed the exam, better luck next time”), Output:, Congratulations! You passed the exam, You are passed in the exam