This program checks whether a number is a Special Number or not. A number is said to be a special number when the sum of the factorial of its digits is equal to the number itself. Example - 145 is a Special Number as 1!+4!+5!=145. Program- /*import java.util.*; public class SpecialNumberCheck { public static void main(String args[]) { Scanner ob=new Scanner(System.in); System.out.println("Enter the number to be checked."); int a=ob.nextInt(); int sum=0,b=a; while(a!=0)//or a>0 { int rem=a%10; int fact=1; for(int i=1;i<=rem;i++) ...
Updating Dictionary You can update a dictionary by adding a new entry or a key-value pair, modifying an existing entry, or deleting an existing entry as shown below in the simple example − When the above code is executed, it produces the following result − dict['Age'] : 8 dict['School'] : DPS School Delete Dictionary Elements You can either remove individual dictionary elements or clear the entire contents of a dictionary. You can also delete the entire dictionary in a single operation. To explicitly remove an entire dictionary, just use the del statement. Following is a simple example − Accessing Values in Tuples To access values in a tuple, use the square brackets for slicing along with the index or indices to obtain the value available at that index. For example − When the above code is executed, it produces the following result − tup1[0] : physics tup2[1:5] : [2, 3, 4, 5] Updating Tuples Tuples are immutable which means you cannot update or change the values of ...