- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 35163 Articles for Programming
13K+ Views
Python functions are used to implement logic that you wish to run repeatedly at various locations across your code. These functions accept function arguments as input parameters. You can specify default argument values in Python functions in addition to supplying parameters to them through function calls. If you don't explicitly specify a parameter value to the given argument, these default values are applied to function arguments. The actual values supplied to function arguments are called parameters. The syntax representation and default values for function parameters are different in Python. If no argument value is given during the function call, default ... Read More
47K+ Views
A type of argument with a default value is a Python optional parameter. A function definition's assignment operator or the Python **kwargs statement can be used to assign an optional argument. Positional and optional arguments are the two sorts of arguments that a Python function can take. Values that are not required to be given in order to call a function are known as optional parameters. Function in Python A function is a section of code that only executes when called. You can supply parameters that is data to a function. As a result, a function may or may not ... Read More
460 Views
In Python, variables are never explicitly typed. Python figures out what type a variable is and keeps track of it internally. In Java, C++, and other statically-typed languages, you must specify the datatype of the function return value and each function argument.If we explicitly define datatype in a python function, it still works like a normal program where data type is not declared explicitly.ExampleWe get the following output for the given codeC:/Users/TutorialsPoint1/~.py The required Sum is: 13.0Consider this functiondef addSum(x, y): return x+y print addSum(2.2, 5.6) print addSum(float(2.2), float(5.6))Output7.8 7.8So the declaration of the datatype of a ... Read More
29K+ Views
Any object, such as dictionary, can be the return value of a Python function. Create the dictionary object in the function body, assign it to any variable, and return the dictionary to the function's caller. Data values are stored as key:value pairs in dictionaries. A Python dictionary is a collection that is ordered, changeable, and forbids duplicates. In this article we will discuss various methods to return a dictionary from a Python function. Using Dictionary Comprehension One line of Python code can create and initialise dictionaries using the simple and memory efficient way known as Dictionary Comprehension. Expression and context ... Read More
2K+ Views
Camel case and snake case are ways of writing words together when we are programming. In camel case, we write words together without spaces and we start each new word with a capital letter except for the first word. For example, if we want to write a variable name for someone's date of birth, we can write it like this: dateOfBirth. In snake case, we write words together with an underscore symbol between them, and all the letters are lowercase. For example, if we want to write a variable name for someone's home address, we can write it like this: ... Read More
214 Views
Documentation is an important aspect of writing code, especially when it comes to functions. It helps others understand what the function does, how to use it, and what parameters it takes. Python has a built-in documentation tool called docstrings. A docstring is a string that appears as the first statement in a function and provides documentation about the function. Information about a function or documentation is put in docstrings in a function. The following are the guidelines to be followed while writing the docstrings.The first line should always be a short, concise summary of the object’s purpose. For brevity, ... Read More
5K+ Views
In this article we will discuss how to delete multiple lines that are repeated in Python. If the file is small and only has a few lines, the process of removing repeated lines from it could be performed manually. However, when dealing with huge files, Python can assist. Using File Handling Method Python has built-in methods for creating, opening, and closing files, which makes handling files easier. Python also enables doing several file actions, such as reading, writing, and appending data, while files are open. To remove duplicate lines from a Python text file or function, we use file handling ... Read More
5K+ Views
In python, everything is an object. And every object has attributes and methods or functions. Attributes are described by data variables for example like name, age, height etc. Properties are special kind of attributes which have getter, setter and delete methods like __get__, __set__ and __delete__ methods. A property decorator in Python provides getter/setter access to an attribute. You can define getters, setters, and delete methods with the property function. If you just want the read property, there is also a @property decorator you can add above your method. # create a class class C(object): ... Read More
2K+ Views
Functions accept arguments that can contain data. The function name is followed by parenthesis that list the arguments. Simply separate each argument with a comma to add as many as you like. As the name implies, mandatory arguments are those that must be given to the function at the time of the function call. Failure to do so will lead to a mistake. Simply put, default function parameters are the exact opposite of required arguments. As we previously saw, while declaring the function, we give the function parameters a default value in the case of default arguments. The function automatically ... Read More
To Continue Learning Please Login
Login with Google