Found 33676 Articles for Programming

Python Program to Search an Element in a Dictionary

Utkarsha Nathani
Updated on 24-Apr-2023 12:05:23

19K+ Views

Dictionaries are used to store data values in key:value pairs like maps (which unlike other data types holds only a single value as an element). key:value is provided in dictionaries to make it more effective. Keys are unique. Dictionary key must be unique. So, no duplicate values are allowed in dictionaries. Dictionaries items are ordered, changeable, immutable. Changeable means here is that, we can add or remove items after the dictionaries are created. In this article, we will know about how to search an element in dictionary by using different functions. There are many functions to search an element ... Read More

Python Program to Add Elements to a Dictionary

Utkarsha Nathani
Updated on 24-Apr-2023 12:03:01

191 Views

High-level, all-purpose Python is a very well-liked programming language. Python is utilised for cutting-edge software development projects like web development and machine learning applications. In this article, we will be learning various methods for adding elements to a dictionary. What do You Understand From Dictionary in Python? A dictionary in Python stores a key: value pair, unlike other Data Types that only contain a single value as an element. It is used to store data values like a map. The dictionary includes key-value pairs to help it become more efficient. In a dictionary, each key-value pair is separated ... Read More

How do I declare an array of weak references in Swift?

Nitin Aggarwal
Updated on 24-Apr-2023 11:32:25

1K+ Views

In Swift, you can use the weak keyword to declare an array of weak objects. In this article, we will use the weak keyword to store the weak objects or references in an array. Weak References Weak references are one of the solutions to the retain cycle problem in Swift. Note that a weak reference does not increment or decrement the reference count of an object. They can be deallocated even if ARC has a reference count greater than 1. Basically, we use the weak keyword in Swift to mark a reference as weak. Also, a weak reference cannot be ... Read More

Python Program To Create A Dictionary With A Dictionary Literal

Utkarsha Nathani
Updated on 24-Apr-2023 12:00:28

1K+ Views

Dictionaries are used to store data values in key:value pairs like maps (which unlike other data types holds only a single value as an element). key:value is provided in dictionaries to make it more effective. Keys are unique. Dictionary key must be unique. So, no duplicate values are allowed in dictionaries. Dictionaries items are ordered, changeable, immutable. Changeable means here is that, we can add or remove items after the dictionaries are created. In python, dictionaries are defined as object with the data type ‘dict’. The values in dictionaries items can be of any data type like string, integer, Boolean ... Read More

Python Program to Calculate the Symmetric Difference Between Two Lists

Utkarsha Nathani
Updated on 24-Apr-2023 11:56:01

887 Views

In python, multiple items can be kept in a single variable by using lists. One of the four built-in data types in Python for storing data collections is the list; the other three are the tuple, set, and dictionary, each of which has a unique purpose. What is List? Square brackets are used to build lists. The most effective tool in Python is the list because they don't necessarily have to be homogeneous. Data-Types like Integers, Strings, and Objects can all be found in one list. Because lists are mutable, changes can be made to them even after they ... Read More

Python Program to Rotate Elements of a List

Utkarsha Nathani
Updated on 24-Apr-2023 11:53:46

3K+ Views

Lists can be used in Python to maintain several items in a single variable. The list is one of Python's four built-in data types for storing data collections. The other three, tuple, set, and dictionary, each serve a different function. Lists are constructed using square brackets. Because lists don't have to be homogeneous, they are the most useful tool in Python. One list contains Data-Types like Strings, Objects, and Integers. Lists can be modified after they have been generated because they are mutable. The focus of this article is on shorthand and many quick ways to say this in ... Read More

Swift: #warning equivalent

Nitin Aggarwal
Updated on 24-Apr-2023 11:30:39

302 Views

In Swift, there are some directives to perform some checks at compilation time. Based on that, you can perform initial checks to write better code. In this article, we will see how to use the "#warning" directive with some examples. You can use the #warning directive to issue a warning message at compile-time. This is similar to the #warning directive in C and Objective-C. #warning in Swift In Swift, #warning is a compiler directive that allows you to issue a warning message during compilation. This can be useful for reminding yourself or other developers about areas of the code that ... Read More

Python Program to Replace Elements in a List

Utkarsha Nathani
Updated on 24-Apr-2023 11:51:46

2K+ Views

In python, multiple items can be kept in a single variable by using lists. One of the four built-in data types in Python for storing data collections is the list the other three are the tuple, set, and dictionary, each of which has a unique purpose. What is List? Square brackets are used to build lists. The most effective tool in Python is the list because they don't necessarily have to be homogeneous. DataTypes like Integers, Strings, and Objects can all be found in one list. Because lists are mutable, changes can be made to them even after they ... Read More

Python Program to Convert List into Array

Utkarsha Nathani
Updated on 24-Apr-2023 11:45:46

4K+ Views

What Is List? Lists are constructed using square brackets. The list is the most powerful tool in Python because it does not have to be homogeneous. Integers, Strings, and Objects can all be found in the same list. Because lists are mutable, they can be changed even after they are formed. One of the most important aspects of Python lists is their capacity to include duplicate values. This enables us to loop through the list's entries and find the value of each one. If the value needs to be replaced, we replace it. There will be instances when you ... Read More

Swift Extract Regex Matches

Nitin Aggarwal
Updated on 25-Apr-2023 09:19:26

2K+ Views

In Swift, you can extract regex matches using the NSRegularExpression class provided by the Foundation framework. Swift's NSRegularExpression is a powerful tool for working with regular expressions in Swift. It can be used for a wide range of text-processing tasks. NSRegularExpression Class You can make use of regular expressions with the Swift Foundation framework class called NSRegularExpression. With the help of regular expressions, you may search and replace text as well as create patterns that define collections of strings. You can use NSRegularExpression to convert a string pattern into a regular expression object, which you can then use to find ... Read More

Advertisements