#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, World!");
}
}
📌 Program Title : Check if a number is Even or Odd
🧠 Description :
This program checks whether a given integer is even or odd. An even number is divisible by 2, while an odd number is not. The user is prompted to enter an integer, and the program outputs either "Even" or "Odd" based on the result.
📥 Input: An integer (e.g., 7)
📤 Output: A single word:
"Even" – if the number is divisible by 2
"Odd" – otherwise
🧪 Example:
🧠 Description :
This program checks whether a given integer is even or odd. An even number is divisible by 2, while an odd number is not. The user is prompted to enter an integer, and the program outputs either "Even" or "Odd" based on the result.
📥 Input: An integer (e.g., 7)
📤 Output: A single word:
"Even" – if the number is divisible by 2
"Odd" – otherwise
🧪 Example:
Input: 4
Output: Evennum = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
let num = parseInt(prompt("Enter a number:"));
if (num % 2 === 0) {
console.log("Even");
} else {
console.log("Odd");
}#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
if (num % 2 == 0)
printf("Even\n");
else
printf("Odd\n");
return 0;
}
#include <iostream>
using namespace std;
int main() {
int num;
cin >> num;
if (num % 2 == 0)
cout << "Even";
else
cout << "Odd";
return 0;
}
OverAPI provides cheat sheets for multiple programming languages and technologies in one place. It’s especially useful for quick syntax reference while coding or revising concepts
You can find concise guides for languages and tools like JavaScript, Python, Java, PHP, SQL, HTML, CSS, and more — all organised in an easy-to-read format
This resource is ideal for students, developers, and anyone who wants to code faster without constantly searching documentation
For more useful coding resources, tools, and tech discoveries, feel free to follow the page
You can find concise guides for languages and tools like JavaScript, Python, Java, PHP, SQL, HTML, CSS, and more — all organised in an easy-to-read format
This resource is ideal for students, developers, and anyone who wants to code faster without constantly searching documentation
For more useful coding resources, tools, and tech discoveries, feel free to follow the page
Overapi
OverAPI.com | Collecting all the cheat sheets
OverAPI.com is a site collecting all the cheatsheets,all!
import telebot
from telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton
token = '68613996:AAFG6d8Q92kKqzG8kY7Negg7sCT83ApBEP8' #bot token from @botfather
bot = telebot.TeleBot(token)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == 'test':
bot.send_message(call.message.chat.id, 'You clicked on Test Callback (Inline) Button')
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, 'Hello!')
markup = ReplyKeyboardMarkup(resize_keyboard=True)
markup.add(KeyboardButton('Test'))
bot.send_message(message.chat.id, 'Hello choose a button',reply_markup=markup)
@bot.message_handler(commands=['inline'])
def inline_key(message):
markup = InlineKeyboardMarkup()
markup.add(InlineKeyboardButton('Test', callback_data='test'))
bot.send_message(message.chat.id, 'Hello choose a button',reply_markup=markup)
@bot.message_handler(content_types=['text'])
def msg_handler(message):
user_id = message.chat.id
if message.text == 'Test':
bot.reply_to(message,"You choosen Test Button")
return
bot.send_message(user_id,message.text)
bot.polling(non_stop=True)
Designing APIs for humans: Object IDs 🧑🏻💻
Ever wondered why Stripe uses foloowing format to generate unique IDs? Let’s dive in and break down how and why Stripe IDs are structured the way they are:
pi_3LKQhvGUcADgqoEM3bh6pslE
└┘└────────────┘
└─ Prefix └─ Randomly generated characters
You might have noticed that all Stripe Objects have a prefix at the beginning of the ID. The reason for this is quite simple: adding a prefix makes the ID human readable. ✔️
Without knowing anything else about the ID we can immediately confirm that we’re talking about a PaymentIntent object here, thanks to the pi_ prefix. This helps Stripe employees internally just as much as it helps developers integrating with Stripe.
The above snippet is trying to retrieve a PaymentIntent from a connected account, however without even looking at the code you can immediately spot the error: a Customer ID (cus_) is being used instead of an Account ID (acct_). 🔖
Without prefixes this would be much harder to debug; if Stripe used UUIDs instead then we’d have to look up the ID to find out what kind of object it is and if it’s even valid 👨💻
Ever wondered why Stripe uses foloowing format to generate unique IDs? Let’s dive in and break down how and why Stripe IDs are structured the way they are:
pi_3LKQhvGUcADgqoEM3bh6pslE
└┘└────────────┘
└─ Prefix └─ Randomly generated characters
You might have noticed that all Stripe Objects have a prefix at the beginning of the ID. The reason for this is quite simple: adding a prefix makes the ID human readable. ✔️
Without knowing anything else about the ID we can immediately confirm that we’re talking about a PaymentIntent object here, thanks to the pi_ prefix. This helps Stripe employees internally just as much as it helps developers integrating with Stripe.
$pi = $stripe->paymentIntents->retrieve(
$id,
[],
['stripe_account' => 'cus_1KrJdMGUcADgqoEM']
);
The above snippet is trying to retrieve a PaymentIntent from a connected account, however without even looking at the code you can immediately spot the error: a Customer ID (cus_) is being used instead of an Account ID (acct_). 🔖
Without prefixes this would be much harder to debug; if Stripe used UUIDs instead then we’d have to look up the ID to find out what kind of object it is and if it’s even valid 👨💻
JavaScript Clean Code 🛠
Only comment things that have business logic complexity
Comments are an apology, not a requirement. Good code mostly documents itself
Bad :
function hashIt(data) {
// The hash
let hash = 0;
// Length of string
const length = data.length;
// Loop through every character in data
for (let i = 0; i < length; i++) {
// Get character code.
const char = data.charCodeAt(i);
// Make the hash
hash = ((hash << 5) - hash) + char;
// Convert to 32-bit integer
hash &= hash;
}
}Good :
function hashIt(data) {
let hash = 0;
const length = data.length;
for (let i = 0; i < length; i++) {
const char = data.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
// Convert to 32-bit integer
hash &= hash;
}
}#JSTips #CodewithKushal
#Programmers
Please open Telegram to view this post
VIEW IN TELEGRAM
*Data Handling Basics Part 1: NumPy (Numerical Computing in Python)* 🐱
NumPy is one of the most important libraries for:
- Data science
- Machine learning
- Scientific computing
- Data analytics
It provides fast mathematical operations on arrays.
1) Install NumPy*
pip install numpy
2) Import NumPy*
import numpy as np
np is the standard alias.
3) Create NumPy Array*
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr)
Output: [1 2 3 4]
4) NumPy vs Python List*
Python list:
a = [1,2,3]
b = [4,5,6]
print(a + b)
Output: [1,2,3,4,5,6]
NumPy array:
import numpy as np
a = np.array([1,2,3])
b = np.array([4,5,6])
print(a + b)
Output: [5 7 9]
NumPy performs element-wise operations.
5) Basic Array Operations*
import numpy as np
arr = np.array([1,2,3,4])
print(arr + 10)
print(arr * 2)
Output:
[11 12 13 14]
[2 4 6 8]
6) Useful NumPy Functions*
import numpy as np
arr = np.array([1,2,3,4])
print(np.mean(arr))
print(np.sum(arr))
print(np.max(arr))
print(np.min(arr))
Output example:
2.5
10
4
1
7) Create Special Arrays*
- Zeros array:
- Ones array:
- Range array:
8) 2D Arrays (Matrices)*
import numpy as np
arr = np.array([
[1,2,3],
[4,5,6]
])
print(arr)
Access element:
Output: 2
*Real Example: Student Marks Analysis*
import numpy as np
marks = np.array([78,85,90,66,72])
print("Average:", np.mean(marks))
print("Highest:", np.max(marks))
print("Lowest:", np.min(marks))
*Practice Tasks*
1. Create NumPy array of numbers 1–10
2. Add 5 to every element
3. Find mean and sum of array
4. Create 3×3 matrix
5. Find maximum value in array
NumPy is one of the most important libraries for:
- Data science
- Machine learning
- Scientific computing
- Data analytics
It provides fast mathematical operations on arrays.
1) Install NumPy*
pip install numpy
2) Import NumPy*
import numpy as np
np is the standard alias.
3) Create NumPy Array*
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr)
Output: [1 2 3 4]
4) NumPy vs Python List*
Python list:
a = [1,2,3]
b = [4,5,6]
print(a + b)
Output: [1,2,3,4,5,6]
NumPy array:
import numpy as np
a = np.array([1,2,3])
b = np.array([4,5,6])
print(a + b)
Output: [5 7 9]
NumPy performs element-wise operations.
5) Basic Array Operations*
import numpy as np
arr = np.array([1,2,3,4])
print(arr + 10)
print(arr * 2)
Output:
[11 12 13 14]
[2 4 6 8]
6) Useful NumPy Functions*
import numpy as np
arr = np.array([1,2,3,4])
print(np.mean(arr))
print(np.sum(arr))
print(np.max(arr))
print(np.min(arr))
Output example:
2.5
10
4
1
7) Create Special Arrays*
- Zeros array:
np.zeros(5)- Ones array:
np.ones(4)- Range array:
np.arange(1,10)8) 2D Arrays (Matrices)*
import numpy as np
arr = np.array([
[1,2,3],
[4,5,6]
])
print(arr)
Access element:
print(arr[0,1])Output: 2
*Real Example: Student Marks Analysis*
import numpy as np
marks = np.array([78,85,90,66,72])
print("Average:", np.mean(marks))
print("Highest:", np.max(marks))
print("Lowest:", np.min(marks))
*Practice Tasks*
1. Create NumPy array of numbers 1–10
2. Add 5 to every element
3. Find mean and sum of array
4. Create 3×3 matrix
5. Find maximum value in array
*✔️ Practice Task Solutions — NumPy Basics*
*Task 1. Create NumPy array of numbers 1–10*
import numpy as np
arr = np.arange(1, 11)
print(arr)
Output: [1 2 3 4 5 6 7 8 9 10]
*Task 2. Add 5 to every element*
import numpy as np
arr = np.arange(1, 11)
result = arr + 5
print(result)
Output: [ 6 7 8 9 10 11 12 13 14 15]
*Task 3. Find mean and sum of array*
import numpy as np
arr = np.array([1,2,3,4,5])
print("Sum:", np.sum(arr))
print("Mean:", np.mean(arr))
Output example:
Sum: 15
Mean: 3.0
*Task 4. Create 3×3 matrix*
import numpy as np
matrix = np.array([
[1,2,3],
[4,5,6],
[7,8,9]
])
print(matrix)
Output:
[[1 2 3]
[4 5 6]
[7 8 9]]
*Task 5. Find maximum value in array*
import numpy as np
arr = np.array([12,45,7,89,34])
print("Maximum:", np.max(arr))
Output: Maximum: 89
*✔️ Key learning*
- np.arange() → create range arrays
- NumPy supports vectorized operations
- np.mean() → average
- np.sum() → total
- np.max() → largest value
Please open Telegram to view this post
VIEW IN TELEGRAM
Listing Content Of Directory In Java 📁
In order to list the contents of a directory, below program can be used 🗄
This program simply receives the names of the all sub-directory and files in a folder in an Array and then that array is sequentially traversed to list all the contents
import java.io.*;
public class ListContents {
public static void main(String[] args) {
File file =
new File("//home//user//Documents/");
String[] files = file.list();
System.out.println (
"Listing contents of " + file.getPath()
);
for(int i=0 ; i < files.length ; i++) {
System.out.println(files[i]);
}
}
}
Compare two string by equals() instead == in java 💡
Use equals() because this method internally checks == plus co hontent equality check ☑️
[ CODE ]
public class Test {
public static void main(String[] args) {
String s1 = "string";
String s2 = "string";
String s3 = new String("string");
String s4 = s3;
String s5 = "str"+"ing";
System.out.println("s1==s2 :"+(s1==s2));
System.out.println("s1==s3 :"+(s1==s3));
System.out.println(
"s1.equals(s3) :"+s1.equals(s3)
);
System.out.println("s3==s4 :"+(s3==s4));
System.out.println(
"s3.equals(s4) :"+s3.equals(s4)
);
System.out.println("s1==s5 :"+(s1==s5));
System.out.println(
"s1.equals(s5) :"+s1.equals(s5)
);
}
}[ RESULT ]
s1==s2 :true
s1==s3 :false
s1.equals(s3) :true
s3==s4 :true
s3.equals(s4) :true
s1==s5 :true
s1.equals(s5) :true
C# 14 - Extension Members
C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods.
You can also declare extension members that extend the type, rather than an instance of the type. In other words, these new extension members can appear as static members of the type you extend.
The following code example shows an example of the different kinds of extension members you can declare:
public static class Enumerable
{
// Extension block
extension<TSource>(IEnumerable<TSource> source) // extension members for IEnumerable<TSource>
{
// Extension property:
public bool IsEmpty => !source.Any();
// Extension indexer:
public TSource this[int index] => source.Skip(index).First();
// Extension method:
public IEnumerable<TSource> Where(Func<TSource, bool> predicate) { ... }
}
// extension block, with a receiver type only
extension<TSource>(IEnumerable<TSource>) // static extension members for IEnumerable<Source>
{
// static extension method:
public static IEnumerable<TSource> Combine(IEnumerable<TSource> first, IEnumerable<TSource> second) { ... }
// static extension property:
public static IEnumerable<TSource> Identity => yield return default;
}
}