Tuesday, February 3, 2026

Maturity value at Compound Interest



Java program to convert Decimal to Binary

 import java.util.Scanner;

class D2B

{

public static void main(String[] args)

{

System.out.print("Enter a decimal number :");

Scanner sc = new Scanner(System.in);

int num = sc.nextInt();

String binary = "";

while(num/2 > 0)

{

binary = num%2 + binary;

num = num/2;

}

binary = 1 + binary;

System.out.print(binary);

}

}


Output:



java string value + int is a string or not?

When a Java String value is concatenated with an int value using the + operator, the result is a String.
This behavior is due to Java's rules for the + operator:
  1. If either operand is a String, the other operand is automatically converted to its string representation (e.g., the integer 10 becomes "10").
  2. The operator then performs string concatenation.

Example:

 String value = "The answer is: ";

int number = 42;


String result = value + number;


// The value of 'result' will be the string "The answer is: 42"


Friday, January 16, 2026

Python Dictionary

 

Removing Dictionary Items

Dictionary items can be removed using built-in deletion methods that work on keys:

  • del: removes an item using its key
  • pop(): removes the item with the given key and returns its value
  • clear(): removes all items from the dictionary
  • popitem(): removes and returns the last inserted key–value pair

Output
{1: 'Geeks', 2: 'For', 3: 'Geeks'}
Geeks
Key: 3, Value: Geeks
{}

Iterating Through a Dictionary

A dictionary can be traversed using a for loop to access its keys, values or both key-value pairs by using the built-in methods keys()values() and items().


Output
1
2
age
Geeks
For
22
1: Geeks
2: For
age: 22

Maturity value at Compound Interest