Python

Working with Binary Files in Python

Binary Files: In Python, a binary file is a file that contains textual and non-textual data, such as images, audio files, video files, and executable programs. Binary files are usually opened in binary mode to avoid any character encoding issues, and they can be read and written using the built-in file handling functions.1) It stores …

Working with Binary Files in Python Read More »

Working with Text Files in Python

Text Files: In Python, a text file is a file that contains human-readable text. Text files are usually created with a text editor, and they can be read and written in Python using the built-in file handling functions.1) They store information in the form of ASCII/Unicode characters.2) Each line of text is terminated or delimited …

Working with Text Files in Python Read More »

File Handling in Python

File: In Python, a file is a named area on disk or in memory used to store data permanently. A file can be used to store text, binary data, or other types of data. Python provides built-in functions and methods for working with files, which allows you to open, create, read, write, append, modify and …

File Handling in Python Read More »

Conditional statements in Python

Conditional Statements: It tests a condition and executes a particular statement or a group of statements depending upon the result of the condition. It is a compound statement i.e. it contains other statements. Python supports following types of conditional statements1) if2) if else3) if elif else4) Nested if else if statement: It tests a condition …

Conditional statements in Python Read More »

Input Output Statements in Python

Input Statements in Python: We can read the variables by using python input() function as:1) We can write any string/text to be displayed at the python prompt as an argument to the input function.2) If we don’t specify any string/text to be displayed at the python prompt , then nothing will be displayed. But we …

Input Output Statements in Python Read More »

Type Conversion in Python

Type Conversion: It means to convert the operands of one data type into another data type. Types of Conversions: Python supports two types of conversions:1) Implicit Type Promotion/ Internal Conversion 2) Explicit Type Casting/ External Conversion 1) Implicit Type Promotion/ Internal Conversion : It is the conversion done by the python compiler/interpreter without user’s intervention.1) …

Type Conversion in Python Read More »

Expressions in Python

Expressions: It is any valid combination of operators and operands (may be literals / variables). It is composed of one or more operations. Example 1) 5 + 4 is valid2) 5 + -4 is valid3) 5 + * 6 is invalid because in this case, compiler will be confused which operation whether + or * …

Expressions in Python Read More »

Flow of Control in Python

Statements Flow Control: It determines the order of execution of statements in a program. Types of Statements Flow Control: There are 3 types of flow control in python.1) Sequential Flow2) Conditional / Branching / Decision Making / Selection Statements3) Iteration/ Repetition/ Looping Statements 1) Sequential Flow: In it, statements are executed in sequence one after …

Flow of Control in Python Read More »

error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.