Codelybrary
My collection of useful facts and experiences.
Tuesday, February 3, 2026
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?
String value is concatenated with an int value using the + operator, the result is a String. + operator: - If either operand is a
String, the other operand is automatically converted to its string representation (e.g., the integer10becomes"10"). - 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
d = {1: 'Geeks', 2: 'For', 3: 'Geeks', 'age':22}# Using del del d["age"]print(d)# Using pop() val = d.pop(1)print(val)# Using popitem()key, val = d.popitem()print(f"Key: {key}, Value: {val}")# Using clear()d.clear()print(d)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().
d = {1: 'Geeks', 2: 'For', 'age':22}# Iterate over keysfor key in d: print(key)# Iterate over valuesfor value in d.values(): print(value)# Iterate over key-value pairsfor key, value in d.items(): print(f"{key}: {value}")Output
1 2 age Geeks For 22 1: Geeks 2: For age: 22
-
//The HTML index page <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change ...
-
Here are some links to online work sites https://www.upwork.com/ https://www.guru.com/ https://studio.envato.com/freelance-switch/ htt...
-
Acronym Full Form AJAX Asynchronous JavaScript and XML API Application Programming Interface APK Android Application Package ASP Activ...
.png)
.png)