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 :.
ReadIn 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.
ReadIn 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.
ReadIn 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 :.
ReadUsing 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.
ReadA 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 :.
ReadA 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`.
ReadPython 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.
ReadWhat 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.
ReadThis 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