python

python

getattr in Python 3 with example

getattr is used to get the attribute of an object. We can also pass one default value to print if the attribute is not found.Before going in details, let's take a look into the following program :.

Read
python

Python program to count the number of words in a file

In this python programming tutorial, we will learn how to count the number of words in a text file.The program will take the file path and print the total word count.

Read
python

Python 3 program to check if a number is positive, negative or zero

In this tutorial, we will learn how to test if a number is positive or negative. We will also check if the number is zero.This is a beginner-friendly python tutorial. With this example, you will learn how to read a user input, how to put your code in a different method to organize it, and how to use an if, else-if, else condition.

Read
python

*args and **kwargs in Python and difference between them

In this python tutorial, we will discuss about two frequently used argument keywords '*args' and '**kwargs' . One thing we should keep in mind that we can use any name instead of 'args' and 'kwargs' for these variables. That means you can use any name like '*myargs' , '**mykwargs' etc. Let me show you what are the purpose of these two variables :.

Read
python

Write a python program to find the number of CPU count

Using python, we can easily check the number of CPUs available in a system. In this example program, we will learn two different methods to get this count.

Read
python

What is Docstring and how to write docsrting in python

A docstring is a string that is used for documentation of a module,function,class or method in python. This string comes as the first statement after the name of the function , module etc . The value of a docstring can be printed out by using doc attribute of the object. So, if you want to know what a system module does, just print out its docstring. e.g. to know about 'int', use the following :.

Read
python

Python Program to find if a number is Armstrong or not

A three-digit number is called an Armstrong number if the sum of cube of its digits is equal to the number itself.For example, 407 is an Armstrong number since` 4****3 + 0****3 + 7****3 = 64 + 0 + 343 = 407`.

Read
python

Python program to sort all words of a string in alphabetical order

Python program to sort all words of a string in alphabetical order. This python program will take one string as input and sort all words of that string alphabetically.

Read
python

Python Program to find the LCM of two numbers

What is an LCM value of two numbers? LCM or least common multiplier of two numbers is the smallest number that is divisible by both of these numbers. i.e. the lowest number starting from 1, that is divisible by both.

Read
python

How to check if a date is valid or not in python

This tutorial is to find out if a date is valid or not using python. If a date actually exists in the calendar, it is called valid. We will write one python program to check the validity of any user-provided date.

Read