Download as pdf
Download as pdf
You are on page 1of 3
CHAPTER 6- INTRODUCING PYTHON Brain Developer A. Fill in the blanks: 1. Syntax 2. Guido Van Rossum 3. Edit 4, Line by line 5. Variable 6. Keyword B. State True or False: True True True False False True . True C. Application Based Questions: 1, Kritika should use '\t' separator with the print() function. 2. Aman should use Interactive mode. D. Multiple Choice Questions: 1. ¢) List 2. b) Overwritten 3. ¢) Assignment 4. b) float S. a) \t 6. c) Script area 7. b) 1020 E. Answer the following: 1. Some of the features which make Python so popular are as follows: + Itis an easy to learn general-purpose programming language. * Itis a platform independent programming language, which means it can be used on any machine and in any operating system. + Ithas a simple syntax. * Python is a case sensitive language. * Itis an interpreted language. * It is free to use and even for commercial products, 2. Avariable stores data values. It can store only one data value at a time. When a new value is stored in a variable, its previous value gets overwritten, The rules for valid identifier (variable name) are: . A variable name must start with an alphabet (capital or small) or an underscore (_ ). * Avariable name can consist of alphabets, digits, and underscore. No other character is allowed. * APython keyword cannot be used as a variable name. © Avariable name can be of any length. Variable names are case-sensitive (e.g., Age and age are different variable names). 3. Python works in two modes: Interactive mode and Script mode. Moyaenre In the Interactive mode of Python, the instructions are executed line by line giving the output. Interactive mode is preferred for small programs, where only a few commands are to be executed. This mode is also beneficial for testing code where you type the commands one at a time and get the result or error immediately. Whereas, for writing lengthy programs in Python, Script mode is used. Using this mode, we can Create and edit Python programs. In this mode, we can save our file so that it can be used later. The complete script is written in an editor, such as a Notepad in Windows. A data type represents the type of data stored in a variable. Python has various standard data types based on the types of values stored in variables. Some examples of data types used in Python are, int, float, str, bool. float: Represents floating point values (numbers with fractional part). The fractional part of a floating point number may be 0 as well. Examples of floating point numbers are, 3.14, -48.6, 18.0, etc. str (String): String data type represents strings of characters enclosed within quotation marks, for example, ‘Hello’. . The print() function is used to display the output of any command on the screen. We can also pass more than one argument to the print()function. Separators are used with the print() function to format the output. The separators used in Python are- Using ',' operator : When you use ',' operator as the separator among the values, the values are displayed with a space between them. Using '\t' (tab space): When you use ‘\t' escape sequence as the separator among the values, the values are displayed with a tab space between them. Using '\n' (Newline character): A newline character in Python is used to end a line and start a new line. In Python, the new line character can be used with the input function and with the print function. Interpreter is a language processor. When you type a command next to the python prompt (>>>) in the interactive mode of Python, and press the Enter key, the interpreter converts the command into machine language. After processing, the interpreter again converts the machine code into human readable form (output). A compiler is also a language processor that converts a program written in high-level language into machine language, and vice versa, just like an interpreter. However, unlike an interpreter, a compiler does this in one single step.

You might also like