The document provides a comprehensive overview of Python programming, including definitions, features, applications, and basic concepts such as variables, data types, and comments. It explains the use of functions like print() and input(), as well as the significance of tokens and keywords in Python. Additionally, it covers the modes of working in Python and offers examples to illustrate various programming principles.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Python Revision
The document provides a comprehensive overview of Python programming, including definitions, features, applications, and basic concepts such as variables, data types, and comments. It explains the use of functions like print() and input(), as well as the significance of tokens and keywords in Python. Additionally, it covers the modes of working in Python and offers examples to illustrate various programming principles.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5
Python Revision notes
1 What is a computer program?
Ans A computer program is a set of instructions that a computer follows to complete a task. 2 What is python? Ans Python is a simple programming language used to write a computer program. It isa easy to learn programming language. 3 What are the applications of python? Ans a) To develop games. b) Build websites c) Program robots using AI d) Perform scientific calculations. 4 What are the features of python? Ans a) Python is a programmer friendly language. b) It is easy to learn. c) Python is a platform independent language. d) Python is an interpreted language. e) It is an object oriented programming language. f) Python is a case sensitive language 5 What are two modes of working in Python? Ans a) Interactive mode-line by line execution of command happens. there is no need to save file while working in interactive mode b) Script mode-complete program is written first and then the execution happens. Saving program is necessary before executing it. 6 What is the use of print() in python? Ans print() function is used to display the output of any command on the screen. For eg. print(‘hello world’) will print hello world on the output screen 7 What are variables? List rules for naming variables. Ans Variables are containers for storing data values. A variable is a named memory location that stores the data and can be changed during the program execution. Rules for naming variables: a) A variables name can only contain alphabets, digits, underscore. b) A variable’s name can be started with an alphabet/underscore but can’t start with a digit. c) We cannot use keywords as names of variables viz print, int, float etc. 8 Multiple assignment of variables? Ans a) Python allows a single value to be assigned to multiple variables simultaneously. Example x=y=z=1 b) We can assign different values to multiple variables in a single line. m1,m2,m3=12,15,18
9 Fill in the blanks:
a) Python is a high level programming language. b) In the python IDLE we type and execute our code in script area. c) Executing a python script or code in the python idle is called interactive mode. d) A variables name can be started with an alphabet or underscore. e) int,print,for,if are examples of keywords. f) Single line comments in python code are written using the # sign. g) Syntax refers to the rules to be followed while writing a program in any language. h) In the python code, we use indentation to define a block of code. i) In python code 90.87 is an example of float datatype. j) ‘\t’ and ‘\n’ are examples of escape sequences. k) Program elements whose value remains to be constant during the execution are literals. l) Is Boolean a basic datatype supported in python yes 10 What are comments? Explain type of comments in python. Ans Comments are used to explain the code. Python interpreter ignores the comments. a) Single line comment: they are written using # (hash) sign. Example:#this is a comment. b) Multi-line comment: starts and ends with triple quotes. Example:’’’ this is a multiline comment starts and ends with triple quotes’’’ 11 What are tokens in python? Ans The smallest individual unit in a program is called token. Python has following tokens: a) Keywords b) Identifiers c) Literals d) Operators 12 Define the following: Ans a) Keyword: Keyword is a predefined word that gives special meaning to the compiler.They are reserved words which has predefined meaning to the compiler. Eg. False, if, True, print, int etc. b) Identifiers: Identifiers are fundamental building blocks of a program and are used to name the programming elements such as user-defined names, variables, modules and other objects. c) Literals: Literals also referred to as constant values are the data items that have a fixed value like 345,suveer,76.97 etc. d) Operators: Operators are special symbols used for carrying out operations on variables and values. For eg. + Addition - Subtraction * Multiplication / Division % Modulus-it returns remainder as an answer 13 What are datatypes? Ans The type of data stored in a variable is represented by a datatype. For example person’s age is represented as numeric value, name is stored as string. int(integer): it can store the integer values that can be positive or negative like 43,5678,-987654 etc float: it is used to store floating point values like 7.5, 89.67, -98.765 etc str(String) : A string datatype represents a string of characters enclosed within single or double quotation marks.eg. “hello”,”123”,’book’ etc 14 Define input() function. Ans The input() function is used to take input from the user instead of assigning a fixed value to a variable. Input function take input from the user as a string and then convert it to required datatype. For eg int(input(‘enter number’)) will convert entered string into a integer. 15 Give use of following escape sequences: Ans a) ‘\t’ :gives a tab space between two characters. b) ‘\n’: this is called as newline character is used to end a line and start a new line
16 Who invented python?
Ans Guido Van Rossum 17 What is the extension for saving a python file Ans .py 18 What will be the output of ‘6’*’6’ Ans It will result in an error as 6 is written in single quotes which is the syntax for writing a string and strings cannot be multiplied. 19 What will be the output of 6*6 Ans 36