Month: March 2021

Java tutorials for Beginners – Java TreeSet

(Java programming Example for Beginners) Java TreeSet In this tutorial, we will learn about the Java TreeSet class and its various operations and methods with the help of examples. The TreeSet class of the Java collections framework provides the functionality of a tree data structure. It extends the NavigableSet interface. Creating a TreeSet In order to create a …

Python Example – Write a Python program to shuffle the following elements randomly

(Python Example for Beginners)   Write a Python program to shuffle the following elements randomly.   Sample Solution: Python Code: import random nums = [1, 2, 3, 4, 5, 6, 7] random.shuffle(nums) print(nums) Sample Output: [5, 3, 4, 7, 1, 6, 2]     Python Example – Write a Python program to shuffle the following …

Java tutorials for Beginners – Java SortedSet Interface

(Java programming Example for Beginners) Java SortedSet Interface In this tutorial, we will learn about the SortedSet interface in Java and its methods with the help of an example. The SortedSet interface of the Java Collections framework is used to store elements with some order in a set. It extends the Set interface. Class that implements SortedSet In …

Python Example – Write a Python program to generate random integers in a specific numerical range

(Python Example for Beginners)   Write a Python program to generate random integers in a specific numerical range.   Sample Solution: Python Code: import random for x in range(6): print(random.randrange(x, 100), end=’ ‘) Sample Output: 21 55 48 50 27 5     Python Example – Write a Python program to generate random integers in …

Java tutorials for Beginners – Java LinkedHashSet

(Java programming Example for Beginners) Java LinkedHashSet In this tutorial, we will learn about the Java LinkedHashSet class and its methods with the help of examples. The LinkedHashSet class of the Java collections framework provides functionalities of both the hashtable and the linked list data structure. It implements the Set interface. Elements of LinkedHashSet are stored in hash tables similar …

Python Example – Write a Python program to generate random float numbers in a specific numerical range

(Python Example for Beginners)   Write a Python program to generate random float numbers in a specific numerical range.   Sample Solution: Python Code: import random for x in range(6): print(‘{:04.3f}’.format(random.uniform(x, 100)), end=’ ‘) Sample Output: 54.737 19.032 9.527 19.097 17.633 41.780     Python Example – Write a Python program to generate random float …

Python Example – Write a Python program to display the fraction instances of the string representation of a number

(Python Example for Beginners)   Write a Python program to display the fraction instances of the string representation of a number.   Sample Solution: Python Code: import fractions for s in [‘0.7’, ‘2.5’, ‘9.32’, ‘7e-1’]: f = fractions.Fraction(s) print(‘{0:>4} = {1}’.format(s, f)) Sample Output: 0.7 = 7/10 2.5 = 5/2 9.32 = 233/25 7e-1 = …

Java tutorials for Beginners – Java HashSet Class

(Java programming Example for Beginners) Java HashSet Class In this tutorial, we will learn about the Java HashSet class. We will learn about different hash set methods and operations with the help of examples. The HashSet class of the Java Collections framework provides the functionalities of the hash table data structure. It implements the Set interface. Creating a …

Java tutorials for Beginners – Java ConcurrentHashMap

(Java programming Example for Beginners) Java ConcurrentHashMap In this tutorial, we will learn about the Java ConcurrentHashMap class and its operations with the help of examples. The ConcurrentHashMap class of the Java collections framework provides a thread-safe map. That is, multiple threads can access the map at once without affecting the consistency of entries in a map. …

Java tutorials for Beginners – Java EnumMap

(Java programming Example for Beginners) Java EnumMap In this tutorial, we will learn about the Java EnumMap class and its operations with the help of examples. The EnumMap class of the Java collections framework provides a map implementation for elements of an enum. In EnumMap, enum elements are used as keys. It implements the Map interface. Before we learn about EnumMap, …