In this example, you will learn how to create a Python program to set the alarm for a particular time. Python Program for Wake-up Alarm The following Python program will create a wake-up alarm. Change the alarm.wav file with your ...
Discy Latest Articles
Python Append List to List Example
In this example, you will learn how to append a list to a list in Python. Append List to List Python Program Example The following Python program will create a fruit list and a vegetable list; then, it will append ...
Built-in methods of Dictionary in Python
len() This method is used to return the length of the dictionary. That is, the number of items (key-value pairs) Example: dict1={'name':'john','course':'B.Tech','Stipen':9000} print(len(dict1)) Output: 3 clear() This method to delete all entries in the dictionary. Example: dict1={'name':'john','course':'B.Tech','Stipen':9000} dict1.clear() print(dict1) Output: ...
Built-In methods of List in Python
append() This method is used to append an element to the list. Example: num_list=[1,2,3,4,5] num_list.append(6) print(num_list) Output: [1, 2, 3, 4, 5, 6] count() This method is used to count the number of times an element appears in the list. ...
Built-In String Methods and Functions in Python
capitalize() This function is used to capitalize the first letter of the string. Example: str="hello world" print(str.capitalize()) Output: Hello world count(str, beg, end) This function is used to count the number of times str occurs in a string. We can ...
Name of Module, Making our own modules in Python
Name of Module Every module has a name. We can find the name of a module by using the __name__attribute of the module. Actually, for every standalone program written by the user, the name of the module is _main_. Example: ...
Modules in Python
In Python, modules are pre-written pieces of code that are used to perform common tasks like generating random numbers, performing mathematical operations, etc. It allows us to reuse one or more functions in a program, even in the programs in ...
Recursive Function in Python
In Python, a recursive function is defined as a function that calls itself to solve a smaller version of its task until a final call is made, which does not require a call to itself. Every recursive solution has two ...
Lambda Function in Python
Lambda functions are throw-away functions, i.e., they are just needed; they have been created and can be used anywhere a function is required. Lambda functions are so-called because they are not declared as other functions using the keyword def. They ...
Defining Function in Python
Function definition with required arguments: For required arguments, the arguments are passed to a function in correct positional order. Also, the number of arguments in the function call is exactly matched with the number of arguments specified in the function ...