Introduction to Programming - O Level Python Notes


1. Discuss the advantages of assembly language over machine language.  

Ans- Advantage of assembly language over machine language are follows:

a) Programs can easily written in alphanumeric symbols instead of 0’s and 1’s. Meaningful and easily rememberable symbols are selected for this purpose. For example, ADD for addition, SUB for subtraction, CMP for comparison, etc. Such symbols are known as mnemonics.

b) Writing programs in assembly language saves programmer’s time. Fewer errors are made, and those that are made are easier to locate. Thus, writing of program in assembly language is easier and faster as compared to writing programs in a machine language.

c) Modification of assembly language programs is easier than machine language program.

2. Differentiate between syntax errors and runtime errors.

ANS- 
a) Syntax error messages-
Syntax or compilation error, are detected and displayed by the complier as it attempts to translate our program. If a statement has a syntax error, it cannot be translated and our program will not be executed.

b) Run time error message-
Runtime errors are detected by the computer and displayed during execution of the program. The runtime errors occurs when the program directs the computer to perform an illegal operation, such as dividing a number by zero. When runtime error occurs, the computer will stop executing our program and will print a diagnostic message that indicates the line where the error was detected.

3. Write the name of few high-level programing language.

ANS- Example of latest high-level language are java, c, c++, python, visual basic, perl, ruby, PHP, etc.

4. What do you understand by compilation and execution of  a program ?

ANS- To translate the sources code of a program written in a high-level language into object code prior to execution of the program is known as compilation. The program that performs task is known as compilation. Now, the object code made after compilation, is linked with other library codes which are needed for execution of the program, The resulting code is known as executable code. After successful compilation, we get file with .exe is created. After executing the .exe file, the result  is obtained.

5. What do you mean by documentation of a program? what is the importance of documentation?

ANS- Documentation of a program involve collecting, organizing, storing and maintaining a complete historical record of programs and other documents used or prepared during different phases of the system development. The main aim of documentation are as follows:

(a) To make available a clear description of the work done so far and help in the design of the system by working to a set of standards. The documentation needs to be kept up to date through out the project.

(b) Good documentation ensures that everyone involved in the system design (namely system designers, programmers and users) fully understands how their part of the system will work. For example, what data will be inputted and how, and what information will be available from the system.

6. How do syntax error occur ? Explain with an example.

ANS- Syntax errors are caused by invalid syntax, for example, entering prnt instead of print in python. Since a translator cannot understand instructions containing syntax errors, it terminates when it encounters such errors, indicating the place where in the program the problem has occurred.

8. What do you mean by semantic error (logical errors)? explain with example.

ANS- Semantic error (logical error) are error in program logic. such error cannot automatically be detected since, translators do not understand the intent of the given computation. For example, if a program computed the average of three numbers as:
 
(num1+num2+num3)/2.0

9. What is program maintenance?

ANS- Program maintenance covers a wide range of activities, including correcting coding and design error, updating documentation and test data and upgrading user’s support. In other words, maintenance may be viewed as enhancements i.e. adding, modifying or developing the code to support change in the specification.

10. Who developed Python Programing Language?

ANS- Guido Van Rossum in 1998s developed Python programming language.

11. Is Python an Object Oriented language? 

ANS- Yes, Python is an Object Oriented language.

12. 'Python is an interpreted high level language' What does mean to you? 

ANS-. 'Python is an high level language' means it is programmer-friendly i.e., easy to program and comprehend.
'Python is an interpreted language' means it requires an interpreter (not compiler) to execute its code line by line -one statement at a time.

13. Python programming language got its name from which show.

ANS- Python programming language was named after a British TV show namely 'Monty Python's Flying Circus'

14. What does a cross platform language means ?

ANS-.  A cross platform language means it can run well on variety of platform like Windows, Linux/Unix, Macintosh etc.

15. Python is a free and open source language. What do you understand by this feature ?

ANS- It means to download python, one needs not pay anything, because it is free. Ad its source-code is also available, which can be modified/improved etc., because it is open-source.

16. What is the difference between interactive mode and script mode in Python ?

ANS- In interactive mode, instruction are given in front of python prompt in Python Shell. Python carries out the given instruction and shows the result itself. In script mode, Python instructions are stored in a file generally with .py extension and are executed together in one go as a unit. The saved instruction are knowns as Python script or Python program.

17. What will be the output of following code:  

        #This is a sample program
        #to output simple statements
        #print(Such as")
        print("Take every chance.")
        print("Drop every fear.")
Pick the correct output from the following choices and give reason. This is asample program to output simple statements  

(a) Such as                         (b)  Such as                            (c) Take every chance. 
     Take every chance.             Take every chance.                Drop every fear.
     Drop every fear.                   Drop every fear.
ANS- The correct output is (c)

Reason being: The code line beginning with # sign are comments. They are just for information and ignored by the Python interpreter . Hence, the third line #print (Such as ) will also be ignored by Python interpreter. Thus, the Python interpreter will give output of only print() statement.

18. Which of the following are not valid strings in Python ?

(a) "Hello"    (b) 'Hello'    (c) "Hello'    (d) 'Hello"    (e) {Hello}

ANS- String(c), (d) and (e) are not valid strings in Python


python tutorial for begginers
python tutorial beginner
python tutorial for beginner
python tutorial beginners 
python questions for practice
python questions and answers 


Post a Comment

0 Comments