Alekhya Nagulavancha has Published 29 Articles

How do we access command line arguments in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 21-Apr-2023 11:54:57

297 Views

Command line is the place where executable commands are given to operating system. A Python script can be executed by writing its name in front of python executable in the command line. C:\users\acer>python test.py If you want some data elements to be passed to Python script for its processing, ... Read More

How do we use Python in script mode?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 19-Apr-2023 14:54:50

2K+ Views

Python is a high level programming language that helps a user to run a program and integrate systems more efficiently; as it executes a program in comparatively fewer lines of code. In this programming language, a code can be run in two ways− Interactive mode, and Script mode ... Read More

How do we use Python in interactive mode?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 19-Apr-2023 14:53:51

1K+ Views

Python is a high level programming language that helps a user to run a program and integrate systems more efficiently; as it executes a program in comparatively fewer lines of code. In this programming language, a code can be run in two ways − Interactive mode, and Script ... Read More

Multi-Line Statements in Python

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 19-Apr-2023 14:28:41

5K+ Views

In Python, statements are nothing but instructions given to a Python interpreter to understand and carry out. These statements are usually written in a single line of code. But, that does not mean Python does not have a provision to write these statements in multiple lines. There are two types ... Read More

What is the best way to run all Python files in a directory?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 19-Apr-2023 14:22:56

2K+ Views

To run a python file in a directory, we generally use the python or python3 command. However, it only runs a single file at a time. But executing one file each on a shell script seems cumbersome. Therefore, we must come up with a way to execute all files present ... Read More

How can I iterate over files in a given directory in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 19-Apr-2023 14:21:12

7K+ Views

Iterating over files in a given directory can be helpful for doing things like finding files that match a certain criterion, or counting the number of files in a directory. Python provides the following five ways to walk through all the existing files in a directory os.listdir() method os.walk() ... Read More

How to catch a python exception in a list comprehension?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 04-Apr-2023 13:38:19

2K+ Views

Before we understand how to catch a Python exception in a list comprehension, let us first learn what a list comprehension is. List comprehension is a statement that allows you to create a list and execute a for loop, all in a single sentence. This also allows the lists to ... Read More

What is the difference between single and double quotes in python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:38:05

4K+ Views

Python uses quotes to represent string objects. They can either be a single quote or double quotes. Both ways are correct and work the same way; however, the difference occurs when these quotes are used together. In this article, we will learn the difference between single quotes and double quotes. ... Read More

How can we read inputs as integers in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:25:34

20K+ Views

In Python, there are two ways to provide input information to a program. One in which we directly assign input objects to object references/variables; and the other in which the program takes user input dynamically (during runtime). Python 2.x versions use raw_input() function to take user input dynamically; whereas, Python ... Read More

How do we write Multi-Line Statements in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:16:12

8K+ Views

A statement is a logical instruction in Python that the Python interpreter can read and execute. It could be an expression or an assignment statement in Python. Python's assignment statement is fundamental. It specifies how an expression generates and stores objects. In a simple assignment, we create new variables, assign ... Read More

Advertisements