๐ง Programming Language Comparison#
Overview Table#
Language |
Description |
Common Challenges |
Most Common Applications |
---|---|---|---|
Visual Basic |
Event-driven language from Microsoft, often used in Windows apps and Excel macros. |
Verbose syntax, limited cross-platform support |
Desktop apps, automation (Excel, Access), legacy systems |
Python |
High-level, interpreted language known for readability and simplicity. |
Slower performance, dynamic typing pitfalls |
Data science, web development, scripting, education |
C# |
Modern, object-oriented language developed by Microsoft for .NET platform. |
Windows-centric ecosystem, verbose generics |
Enterprise apps, game development (Unity), web APIs |
C++ |
Powerful, compiled language with low-level memory control. |
Complex syntax, manual memory management |
Systems programming, embedded systems, high-performance apps |
Java |
Platform-independent, object-oriented language with strong typing. |
Verbosity, slower startup, memory overhead |
Android apps, enterprise software, backend services |
๐ Language Descriptions#
Visual Basic#
Type: Event-driven, imperative
Strengths: Rapid UI development, tight integration with Microsoft Office
Limitations: Less modern tooling, limited portability
Python#
Type: Interpreted, dynamically typed
Strengths: Readable syntax, massive ecosystem (NumPy, Django, etc.)
Limitations: Runtime errors due to dynamic typing, slower than compiled languages
C##
Type: Compiled, statically typed, object-oriented
Strengths: Rich .NET libraries, strong IDE support (Visual Studio)
Limitations: Less portable outside Windows, verbose for some tasks
C++#
Type: Compiled, statically typed, multi-paradigm
Strengths: High performance, fine-grained memory control
Limitations: Steep learning curve, error-prone memory management
Java#
Type: Compiled to bytecode, statically typed, object-oriented
Strengths: Platform independence (JVM), robust ecosystem
Limitations: Verbose syntax, slower than native code
๐ Use Cases by Domain#
Domain |
Recommended Language(s) |
---|---|
Web Development |
Python, Java |
Desktop Applications |
C#, Visual Basic |
Mobile Development |
Java (Android), C# (Xamarin) |
Game Development |
C# (Unity), C++ |
Data Science |
Python |
Systems Programming |
C++ |
Enterprise Software |
Java, C# |
Automation/Scripting |
Python, Visual Basic |
Would you like to extend this with syntax comparisons, demo code blocks, or interactive dropdowns for student exploration?
Visual Basic#
# |
Concept |
Summary |
Advantage |
Application |
---|---|---|---|---|
1 |
Variables and Data Types |
VB uses strongly typed variables like Integer, String, Boolean, etc. |
Improves type safety and clarity |
Used in form controls, calculations, and logic |
2 |
Conditional Statements |
VB supports IfโฆThenโฆElse and Select Case for decision-making |
Simplifies branching logic |
Used in UI validation and control flow |
3 |
Loops |
VB supports For, While, and Do loops for iteration |
Efficient for repetitive tasks |
Used in data processing and UI updates |
4 |
Functions and Subroutines |
Functions return values; Subroutines perform actions |
Encourages modular code |
Used in event handling and logic reuse |
5 |
Event Handling |
VB is event-driven; code responds to user actions like clicks |
Enables interactive applications |
Used in forms, buttons, and controls |
6 |
Forms and Controls |
VB provides drag-and-drop GUI design with controls |
Rapid UI development |
Used in desktop applications and tools |
7 |
Arrays |
VB supports fixed-size and dynamic arrays |
Stores multiple values efficiently |
Used in data grouping and iteration |
8 |
Error Handling |
VB uses TryโฆCatchโฆFinally for exception handling |
Improves program robustness |
Used in file I/O, user input, and APIs |
9 |
File I/O |
VB can read/write files using StreamReader and StreamWriter |
Supports persistent data storage |
Used in logging, config files, and reports |
10 |
Classes and Objects |
VB supports object-oriented programming with classes and inheritance |
Encourages encapsulation and reuse |
Used in large-scale applications and libraries |
import ipywidgets as widgets
from IPython.display import display, Markdown, Code
# ๐ Java Core Concepts (25 total)
java_concepts = {
"1. Variables and Data Types": {
"summary": "Java uses strongly typed variables like int, double, boolean, etc.",
"advantage": "Type safety and memory efficiency",
"application": "Used in calculations, control flow, and logic",
"demo": 'int age = 25;\nSystem.out.println("Age is " + age);'
},
"2. Conditional Statements": {
"summary": "Java supports if, else if, else, and switch.",
"advantage": "Enables decision-making logic",
"application": "Used in UI logic and branching",
"demo": 'int score = 85;\nif (score >= 90) {\n System.out.println("Grade: A");\n} else if (score >= 80) {\n System.out.println("Grade: B");\n}'
},
"3. Loops": {
"summary": "Java supports for, while, and do-while loops.",
"advantage": "Efficient iteration",
"application": "Used in data processing and automation",
"demo": 'for (int i = 1; i <= 5; i++) {\n System.out.println("Count: " + i);\n}'
},
"4. Methods": {
"summary": "Blocks of code that perform tasks and may return values.",
"advantage": "Promotes modular and reusable code",
"application": "Used in event handling and logic reuse",
"demo": 'public int add(int a, int b) {\n return a + b;\n}'
},
"5. Classes and Objects": {
"summary": "Java is object-oriented; everything revolves around classes.",
"advantage": "Encapsulation and reuse",
"application": "Used in application design and modeling",
"demo": 'class Person {\n String name;\n void greet() {\n System.out.println("Hello " + name);\n }\n}'
},
"6. Inheritance": {
"summary": "Allows a class to inherit properties from another.",
"advantage": "Code reuse and hierarchy modeling",
"application": "Used in frameworks and component design",
"demo": 'class Animal {\n void sound() {\n System.out.println("Generic sound");\n }\n}\nclass Dog extends Animal {\n void sound() {\n System.out.println("Bark");\n }\n}'
},
"7. Polymorphism": {
"summary": "Allows methods to behave differently based on context.",
"advantage": "Flexibility and extensibility",
"application": "Used in APIs and dynamic behavior",
"demo": 'Animal a = new Dog();\na.sound();'
},
"8. Abstraction": {
"summary": "Hides implementation details and shows only functionality.",
"advantage": "Simplifies complex systems",
"application": "Used in interfaces and abstract classes",
"demo": 'abstract class Shape {\n abstract void draw();\n}\nclass Circle extends Shape {\n void draw() {\n System.out.println("Drawing Circle");\n }\n}'
},
"9. Encapsulation": {
"summary": "Bundles data and methods together.",
"advantage": "Protects internal state",
"application": "Used in secure and maintainable code",
"demo": 'class Account {\n private int balance;\n public void deposit(int amount) {\n balance += amount;\n }\n}'
},
"10. Interfaces": {
"summary": "Defines a contract for classes to implement.",
"advantage": "Promotes loose coupling",
"application": "Used in design patterns and dependency injection",
"demo": 'interface Drawable {\n void draw();\n}\nclass Square implements Drawable {\n public void draw() {\n System.out.println("Drawing Square");\n }\n}'
},
"11. Exception Handling": {
"summary": "Uses try, catch, finally, and throw.",
"advantage": "Improves program robustness",
"application": "Used in file I/O, user input, and APIs",
"demo": 'try {\n int x = 5 / 0;\n} catch (ArithmeticException e) {\n System.out.println("Error: " + e.getMessage());\n}'
},
"12. File I/O": {
"summary": "Java reads/writes files using FileReader, BufferedReader, etc.",
"advantage": "Persistent data storage",
"application": "Used in config files, logging, and reports",
"demo": 'BufferedReader reader = new BufferedReader(new FileReader("file.txt"));'
},
"13. Collections Framework": {
"summary": "Includes List, Set, Map, etc.",
"advantage": "Efficient data management",
"application": "Used in data structures and algorithms",
"demo": 'List<String> names = new ArrayList<>();\nnames.add("Alice");'
},
"14. Generics": {
"summary": "Enables type-safe data structures.",
"advantage": "Reduces runtime errors",
"application": "Used in reusable libraries and APIs",
"demo": 'List<Integer> numbers = new ArrayList<>();'
},
"15. Multithreading": {
"summary": "Runs multiple threads concurrently.",
"advantage": "Improves performance",
"application": "Used in games, servers, and simulations",
"demo": 'Thread t = new Thread(() -> System.out.println("Running"));'
},
"16. Synchronization": {
"summary": "Controls thread access to shared resources.",
"advantage": "Prevents race conditions",
"application": "Used in concurrent programming",
"demo": 'synchronized void increment() {\n count++;\n}'
},
"17. Lambda Expressions": {
"summary": "Enables concise function-like syntax.",
"advantage": "Improves readability and brevity",
"application": "Used in functional interfaces and streams",
"demo": 'Runnable r = () -> System.out.println("Run");'
},
"18. Streams API": {
"summary": "Processes collections in a functional style.",
"advantage": "Declarative and efficient",
"application": "Used in filtering, mapping, and aggregation",
"demo": 'names.stream().filter(n -> n.startsWith("A")).forEach(System.out::println);'
},
"19. JDBC": {
"summary": "Java Database Connectivity API.",
"advantage": "Enables database interaction",
"application": "Used in enterprise apps and data-driven systems",
"demo": 'Connection conn = DriverManager.getConnection(url, user, pass);'
},
"20. Annotations": {
"summary": "Metadata for code used by compiler or runtime.",
"advantage": "Adds declarative behavior",
"application": "Used in frameworks like Spring and JUnit",
"demo": '@Override\npublic void run() {}'
},
"21. Packages": {
"summary": "Organizes classes into namespaces.",
"advantage": "Improves modularity and reuse",
"application": "Used in library design and code organization",
"demo": 'package com.example.utils;'
},
"22. Access Modifiers": {
"summary": "Controls visibility using public, private, protected.",
"advantage": "Enhances encapsulation",
"application": "Used in API design and secure coding",
"demo": 'private int count;'
},
"23. Static Keyword": {
"summary": "Defines class-level members.",
"advantage": "Saves memory and simplifies access",
"application": "Used in utility methods and constants",
"demo": 'static int counter = 0;'
},
"24. Final Keyword": {
"summary": "Prevents modification of variables, methods, or classes.",
"advantage": "Ensures immutability and safety",
"application": "Used in constants and secure inheritance",
"demo": 'final int MAX = 100;'
},
"25. Constructors": {
"summary": "Special methods to initialize objects.",
"advantage": "Automates object setup",
"application": "Used in object creation and dependency injection",
"demo": 'public Person(String name) {\n this.name = name;\n}'
}
}
# ๐๏ธ Widgets
java_dropdown = widgets.Dropdown(
options=list(java_concepts.keys()),
description="๐ง Java Concept:",
style={'description_width': '160px'},
layout=widgets.Layout(width='600px')
)
java_output = widgets.Output()
def show_java_concept(change):
java_output.clear_output()
with java_output:
concept = change.new
data = java_concepts[concept]
Java#
# |
Concept |
Summary |
Advantage |
Application |
---|---|---|---|---|
1 |
Variables and Data Types |
Java uses strongly typed variables like int, double, boolean, etc. |
Type safety and memory efficiency |
Used in calculations, control flow, and logic |
2 |
Conditional Statements |
Java supports if, else if, else, and switch |
Enables decision-making logic |
Used in UI logic and branching |
3 |
Loops |
Java supports for, while, and do-while loops |
Efficient iteration |
Used in data processing and automation |
4 |
Methods |
Blocks of code that perform tasks and may return values |
Promotes modular and reusable code |
Used in event handling and logic reuse |
5 |
Classes and Objects |
Java is object-oriented; everything revolves around classes |
Encapsulation and reuse |
Used in application design and modeling |
6 |
Inheritance |
Allows a class to inherit properties from another |
Code reuse and hierarchy modeling |
Used in frameworks and component design |
7 |
Polymorphism |
Allows methods to behave differently based on context |
Flexibility and extensibility |
Used in APIs and dynamic behavior |
8 |
Abstraction |
Hides implementation details and shows only functionality |
Simplifies complex systems |
Used in interfaces and abstract classes |
9 |
Encapsulation |
Bundles data and methods together |
Protects internal state |
Used in secure and maintainable code |
10 |
Interfaces |
Defines a contract for classes to implement |
Promotes loose coupling |
Used in design patterns and dependency injection |
11 |
Exception Handling |
Uses try, catch, finally, and throw |
Improves program robustness |
Used in file I/O, user input, and APIs |
12 |
File I/O |
Java reads/writes files using FileReader, BufferedReader, etc. |
Persistent data storage |
Used in config files, logging, and reports |
13 |
Collections Framework |
Includes List, Set, Map, etc. |
Efficient data management |
Used in data structures and algorithms |
14 |
Generics |
Enables type-safe data structures |
Reduces runtime errors |
Used in reusable libraries and APIs |
15 |
Multithreading |
Runs multiple threads concurrently |
Improves performance |
Used in games, servers, and simulations |
16 |
Synchronization |
Controls thread access to shared resources |
Prevents race conditions |
Used in concurrent programming |
17 |
Lambda Expressions |
Enables concise function-like syntax |
Improves readability and brevity |
Used in functional interfaces and streams |
18 |
Streams API |
Processes collections in a functional style |
Declarative and efficient |
Used in filtering, mapping, and aggregation |
19 |
JDBC |
Java Database Connectivity API |
Enables database interaction |
Used in enterprise apps and data-driven systems |
20 |
Annotations |
Metadata for code used by compiler or runtime |
Adds declarative behavior |
Used in frameworks like Spring and JUnit |
21 |
Packages |
Organizes classes into namespaces |
Improves modularity and reuse |
Used in library design and code organization |
22 |
Access Modifiers |
Controls visibility using public, private, protected |
Enhances encapsulation |
Used in API design and secure coding |
23 |
Static Keyword |
Defines class-level members |
Saves memory and simplifies access |
Used in utility methods and constants |
24 |
Final Keyword |
Prevents modification of variables, methods, or classes |
Ensures immutability and safety |
Used in constants and secure inheritance |
25 |
Constructors |
Special methods to initialize objects |
Automates object setup |
Used in object creation and dependency injection |
# โ
Complete the function
def show_java_concept(change):
java_output.clear_output()
with java_output:
concept = change.new
data = java_concepts[concept]
display(Markdown(f"### ๐ Concept: {concept}"))
display(Markdown(f"**Summary**: {data['summary']}"))
display(Markdown(f"**Advantage**: {data['advantage']}"))
display(Markdown(f"**Application**: {data['application']}"))
display(Markdown("**๐งช Demonstration Code (Java syntax):**"))
display(Code(data['demo'], language='text')) # Use 'text' to avoid lexer errors
# โ
Attach the event listener
java_dropdown.observe(show_java_concept, names='value')
# โ
Trigger initial display
java_dropdown.value = list(java_concepts.keys())[0]
# โ
Display layout
display(widgets.VBox([java_dropdown, java_output]))
python#
python_commands = {
"1. print()": {
"summary": "Displays output to the console.",
"advantage": "Simple and universal for debugging.",
"application": "Used in scripts, logging, and teaching.",
"demo": 'print("Hello, world!")'
},
"2. len()": {
"summary": "Returns the length of an object.",
"advantage": "Works on strings, lists, tuples, etc.",
"application": "Used in loops, validation, and slicing.",
"demo": 'name = "Satish"\nprint(len(name))'
},
"3. type()": {
"summary": "Returns the type of an object.",
"advantage": "Useful for introspection and debugging.",
"application": "Used in dynamic typing and validation.",
"demo": 'x = 42\nprint(type(x))'
},
# โ
Continue adding up to 50 commands here
}
python#
import ipywidgets as widgets
from IPython.display import display, Markdown, Code
# ๐ Python Commands Dictionary (50 total)
python_commands = {
"1. print()": {
"summary": "Displays output to the console.",
"advantage": "Simple and universal for debugging.",
"application": "Used in scripts, logging, and teaching.",
"demo": 'print("Hello, world!")'
},
"2. len()": {
"summary": "Returns the length of an object.",
"advantage": "Works on strings, lists, tuples, etc.",
"application": "Used in loops, validation, and slicing.",
"demo": 'name = "Satish"\nprint(len(name))'
},
"3. type()": {
"summary": "Returns the type of an object.",
"advantage": "Useful for introspection and debugging.",
"application": "Used in dynamic typing and validation.",
"demo": 'x = 42\nprint(type(x))'
},
"3. type()": {
"summary": "Returns the type of an object.",
"advantage": "Useful for introspection and debugging.",
"application": "Used in dynamic typing and validation.",
"demo": 'x = 42\nprint(type(x))'
},
"4. range()": {
"summary": "Generates a sequence of numbers.",
"advantage": "Memory-efficient and iterable.",
"application": "Used in loops and indexing.",
"demo": 'for i in range(3):\n print(i)'
},
"5. input()": {
"summary": "Reads user input from the console.",
"advantage": "Interactive and flexible.",
"application": "Used in CLI apps and quizzes.",
"demo": 'name = input("Enter your name: ")\nprint("Hello", name)'
},
"6. int()": {
"summary": "Converts a value to an integer.",
"advantage": "Handles numeric conversion safely.",
"application": "Used in parsing and calculations.",
"demo": 'x = int("42")\nprint(x + 1)'
},
"7. str()": {
"summary": "Converts a value to a string.",
"advantage": "Universal string formatting.",
"application": "Used in logging and display.",
"demo": 'x = 42\nprint("Value: " + str(x))'
},
"8. float()": {
"summary": "Converts a value to a floating-point number.",
"advantage": "Supports decimal precision.",
"application": "Used in scientific and financial calculations.",
"demo": 'x = float("3.14")\nprint(x * 2)'
},
"9. list()": {
"summary": "Creates a list from an iterable.",
"advantage": "Flexible and mutable container.",
"application": "Used in data storage and iteration.",
"demo": 'nums = list(range(5))\nprint(nums)'
},
"10. dict()": {
"summary": "Creates a dictionary from key-value pairs.",
"advantage": "Efficient key-based lookup.",
"application": "Used in configuration and mapping.",
"demo": 'person = dict(name="Satish", age=30)\nprint(person["name"])'
},
"11. set()": {
"summary": "Creates a set of unique elements.",
"advantage": "Removes duplicates automatically.",
"application": "Used in membership testing and deduplication.",
"demo": 'nums = [1, 2, 2, 3]\nprint(set(nums))'
},
"12. tuple()": {
"summary": "Creates an immutable sequence.",
"advantage": "Memory-efficient and hashable.",
"application": "Used in fixed data structures and keys.",
"demo": 'coords = tuple([10, 20])\nprint(coords)'
},
"13. sorted()": {
"summary": "Returns a sorted list from an iterable.",
"advantage": "Does not mutate original data.",
"application": "Used in ranking and display.",
"demo": 'nums = [3, 1, 2]\nprint(sorted(nums))'
},
"14. sum()": {
"summary": "Returns the sum of elements.",
"advantage": "Fast and readable aggregation.",
"application": "Used in statistics and totals.",
"demo": 'nums = [1, 2, 3]\nprint(sum(nums))'
},
"15. max()": {
"summary": "Returns the largest item.",
"advantage": "Efficient comparison.",
"application": "Used in scoring and selection.",
"demo": 'scores = [88, 92, 79]\nprint(max(scores))'
},
"16. min()": {
"summary": "Returns the smallest item.",
"advantage": "Efficient comparison.",
"application": "Used in thresholds and filtering.",
"demo": 'scores = [88, 92, 79]\nprint(min(scores))'
},
"17. abs()": {
"summary": "Returns the absolute value.",
"advantage": "Works on integers and floats.",
"application": "Used in distance and error metrics.",
"demo": 'x = -5\nprint(abs(x))'
},
"18. round()": {
"summary": "Rounds a number to nearest integer or decimal place.",
"advantage": "Supports precision control.",
"application": "Used in formatting and display.",
"demo": 'x = 3.14159\nprint(round(x, 2))'
},
"19. zip()": {
"summary": "Combines multiple iterables element-wise.",
"advantage": "Elegant parallel iteration.",
"application": "Used in pairing and matrix operations.",
"demo": 'names = ["A", "B"]\nscores = [90, 85]\nprint(list(zip(names, scores)))'
},
"20. enumerate()": {
"summary": "Adds index to iterable.",
"advantage": "Useful in loops with position tracking.",
"application": "Used in UI and data labeling.",
"demo": 'for i, val in enumerate(["a", "b"]):\n print(i, val)'
},
"21. help()": {
"summary": "Displays documentation for objects.",
"advantage": "Built-in reference tool.",
"application": "Used in learning and debugging.",
"demo": 'help(str)'
},
"22. dir()": {
"summary": "Lists attributes and methods of an object.",
"advantage": "Useful for introspection.",
"application": "Used in exploration and debugging.",
"demo": 'print(dir(list))'
},
"23. isinstance()": {
"summary": "Checks if an object is an instance of a class.",
"advantage": "Supports type-safe logic.",
"application": "Used in validation and polymorphism.",
"demo": 'print(isinstance(42, int))'
},
"24. id()": {
"summary": "Returns the memory address of an object.",
"advantage": "Helps track object identity.",
"application": "Used in debugging and optimization.",
"demo": 'x = 10\nprint(id(x))'
},
"25. eval()": {
"summary": "Evaluates a string as Python expression.",
"advantage": "Dynamic execution.",
"application": "Used in calculators and interpreters.",
"demo": 'expr = "2 + 3"\nprint(eval(expr))'
},
"26. exec()": {
"summary": "Executes Python code dynamically.",
"advantage": "Flexible code injection.",
"application": "Used in scripting and automation.",
"demo": 'code = "x = 5\\nprint(x)"\nexec(code)'
},
"27. map()": {
"summary": "Applies a function to all items in an iterable.",
"advantage": "Functional and efficient.",
"application": "Used in transformations.",
"demo": 'nums = [1, 2, 3]\nprint(list(map(str, nums)))'
},
"28. filter()": {
"summary": "Filters items using a function.",
"advantage": "Elegant conditional selection.",
"application": "Used in data cleaning.",
"demo": 'nums = [1, 2, 3, 4]\nprint(list(filter(lambda x: x % 2 == 0, nums)))'
},
"29. lambda": {
"summary": "Creates anonymous functions.",
"advantage": "Concise and inline.",
"application": "Used in functional programming.",
"demo": 'square = lambda x: x*x\nprint(square(5))'
},
"30. open()": {
"summary": "Opens a file for reading or writing.",
"advantage": "File I/O interface.",
"application": "Used in data storage and logging.",
"demo": 'with open("test.txt", "w") as f:\n f.write("Hello")'
},
"31. read()": {
"summary": "Reads content from a file.",
"advantage": "Simple file access.",
"application": "Used in data ingestion.",
"demo": 'with open("test.txt", "r") as f:\n print(f.read())'
},
"32. write()": {
"summary": "Writes content to a file.",
"advantage": "Persistent storage.",
"application": "Used in logging and export.",
"demo": 'with open("log.txt", "w") as f:\n f.write("Log entry")'
},
"33. append()": {
"summary": "Adds an item to a list.",
"advantage": "Efficient list growth.",
"application": "Used in data collection.",
"demo": 'lst = []\nlst.append(1)\nprint(lst)'
},
"34. pop()": {
"summary": "Removes and returns an item from a list.",
"advantage": "Supports stack behavior.",
"application": "Used in undo and traversal.",
"demo": 'lst = [1, 2, 3]\nlst.pop()\nprint(lst)'
},
"35. split()": {
"summary": "Splits a string into a list.",
"advantage": "Text parsing tool.",
"application": "Used in tokenization.",
"demo": 'text = "a,b,c"\nprint(text.split(","))'
},
"36. join()": {
"summary": "Joins list elements into a string.",
"advantage": "Efficient string construction.",
"application": "Used in formatting.",
"demo": 'words = ["a", "b"]\nprint(",".join(words))'
},
"37. replace()": {
"summary": "Replaces substrings in a string.",
"advantage": "Text transformation.",
"application": "Used in cleaning and formatting.",
"demo": 'text = "hello world"\nprint(text.replace("world", "Satish"))'
},
"38. strip()": {
"summary": "Removes leading/trailing whitespace.",
"advantage": "Cleans input.",
"application": "Used in preprocessing.",
"demo": 'text = " hello "\nprint(text.strip())'
},
"39. upper()": {
"summary": "Converts string to uppercase.",
"advantage": "Standardizes text.",
"application": "Used in normalization.",
"demo": 'text = "hello"\nprint(text.upper())'
},
"40. lower()": {
"summary": "Converts string to lowercase.",
"advantage": "Standardizes text.",
"application": "Used in normalization.",
"demo": 'text = "HELLO"\nprint(text.lower())'
},
"41. format()": {
"summary": "Formats strings with placeholders.",
"advantage": "Readable and flexible.",
"application": "Used in UI and logging.",
"demo": 'name = "Satish"\nprint("Hello, {}".format(name))'
},
"42. f-strings": {
"summary": "Inline string formatting.",
"advantage": "Concise and readable.",
"application": "Used in dynamic output.",
"demo": 'name = "Satish"\nprint(f"Hello, {name}")'
},
"43. try/except": {
"summary": "Handles exceptions gracefully.",
"advantage": "Improves robustness.",
"application": "Used in error handling.",
"demo": 'try:\n x = 1 / 0\nexcept ZeroDivisionError:\n print("Cannot divide by zero")'
},
"44. import": {
"summary": "Loads external modules.",
"advantage": "Modular and reusable.",
"application": "Used in libraries and packages.",
"demo": 'import math\nprint(math.sqrt(16))'
},
"45. def": {
"summary": "Defines a function.",
"advantage": "Encapsulates logic.",
"application": "Used in modular design.",
"demo": 'def greet(name):\n return f"Hello, {name}"\nprint(greet("Satish"))'
},
"46. class": {
"summary": "Defines a class.",
"advantage": "Supports OOP.",
"application": "Used in modeling and abstraction.",
"demo": 'class Person:\n def __init__(self, name):\n self.name = name\nprint(Person("Satish").name)'
},
"47. __init__": {
"summary": "Constructor method in classes.",
"advantage": "Initializes object state.",
"application": "Used in class instantiation.",
"demo": 'class Car:\n def __init__(self, brand):\n self.brand = brand\nprint(Car("Toyota").brand)'
},
"48. self": {
"summary": "Refers to the instance of a class.",
"advantage": "Accesses attributes and methods.",
"application": "Used in class definitions.",
"demo": 'class Dog:\n def bark(self):\n print("Woof!")\nd = Dog()\nd.bark()'
},
"49. return": {
"summary": "Returns a value from a function.",
"advantage": "Controls output.",
"application": "Used in computation and flow.",
"demo": 'def add(a, b):\n return a + b\nprint(add(2, 3))'
},
"50. pass": {
"summary": "Placeholder for empty blocks.",
"advantage": "Avoids syntax errors.",
"application": "Used in stubs and planning.",
"demo": 'def future_function():\n pass'}
}
# ... continue up to 50
# โ Add commands 11โ50 below following the same structure...
# ๐๏ธ Widgets
command_dropdown = widgets.Dropdown(
options=list(python_commands.keys()),
description="๐ง Python Command:",
style={'description_width': '160px'},
layout=widgets.Layout(width='600px')
)
command_output = widgets.Output()
def show_command(change):
command_output.clear_output()
with command_output:
cmd = change.new
data = python_commands[cmd]
display(Markdown(f"### ๐ Command: `{cmd}`"))
display(Markdown(f"**Summary**: {data['summary']}"))
display(Markdown(f"**Advantage**: {data['advantage']}"))
display(Markdown(f"**Application**: {data['application']}"))
display(Markdown("**๐งช Demonstration Code:**"))
display(Code(data['demo'], language='python'))
# โ
Attach listener and trigger initial display
command_dropdown.observe(show_command, names='value')
command_dropdown.value = list(python_commands.keys())[0]
# ๐ Display UI
display(widgets.VBox([command_dropdown, command_output]))
C++#
import ipywidgets as widgets
from IPython.display import display, Markdown, Code
# ๐ C++ Commands Dictionary (sample of 5 shown; expand to 50)
cpp_commands = {
"1. cout": {
"summary": "Outputs text to the console.",
"advantage": "Standard and widely supported.",
"application": "Used in debugging, logging, and CLI apps.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n cout << "Hello, world!";\n return 0;\n}'
},
"2. cin": {
"summary": "Reads input from the user.",
"advantage": "Simple and direct for console input.",
"application": "Used in interactive programs and quizzes.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n string name;\n cin >> name;\n cout << "Hello " << name;\n return 0;\n}'
},
"3. sizeof": {
"summary": "Returns the size (in bytes) of a data type or variable.",
"advantage": "Useful for memory management and debugging.",
"application": "Used in low-level programming and optimization.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int x;\n cout << sizeof(x);\n return 0;\n}'
},
"4. for loop": {
"summary": "Executes a block of code multiple times.",
"advantage": "Compact and readable iteration.",
"application": "Used in array traversal and counting.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n for (int i = 0; i < 3; i++) {\n cout << i << "\\n";\n }\n return 0;\n}'
},
"5. if statement": {
"summary": "Executes code conditionally.",
"advantage": "Essential for decision-making logic.",
"application": "Used in control flow and branching.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int x = 10;\n if (x > 5) {\n cout << "x is greater than 5";\n }\n return 0;\n}'
},
"6. while loop": {
"summary": "Repeats code while a condition is true.",
"advantage": "Flexible for unknown iteration counts.",
"application": "Used in input validation and polling.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int x = 0;\n while (x < 3) {\n cout << x << "\\n";\n x++;\n }\n return 0;\n}'
},
"7. do-while loop": {
"summary": "Executes code at least once before checking condition.",
"advantage": "Ensures one-time execution.",
"application": "Used in menu-driven programs.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int x = 0;\n do {\n cout << x << "\\n";\n x++;\n } while (x < 3);\n return 0;\n}'
},
"8. switch": {
"summary": "Selects code to execute based on a value.",
"advantage": "Cleaner than multiple if-else blocks.",
"application": "Used in menu systems and state machines.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int choice = 2;\n switch (choice) {\n case 1: cout << "One"; break;\n case 2: cout << "Two"; break;\n default: cout << "Other";\n }\n return 0;\n}'
},
"9. class": {
"summary": "Defines a blueprint for objects.",
"advantage": "Encapsulates data and behavior.",
"application": "Used in object-oriented design.",
"demo": '#include <iostream>\nusing namespace std;\nclass Person {\npublic:\n string name;\n void greet() { cout << "Hello " << name; }\n};\nint main() {\n Person p;\n p.name = "Satish";\n p.greet();\n return 0;\n}'
},
"10. struct": {
"summary": "Groups related variables under one name.",
"advantage": "Lightweight and simple.",
"application": "Used in data modeling and records.",
"demo": '#include <iostream>\nusing namespace std;\nstruct Point {\n int x, y;\n};\nint main() {\n Point p = {1, 2};\n cout << p.x << ", " << p.y;\n return 0;\n}'
},
"11. namespace": {
"summary": "Organizes code into logical groups.",
"advantage": "Prevents naming conflicts.",
"application": "Used in libraries and modular code.",
"demo": 'namespace Math {\n int add(int a, int b) { return a + b; }\n}\n#include <iostream>\nusing namespace std;\nint main() {\n cout << Math::add(2, 3);\n return 0;\n}'
},
"12. #include": {
"summary": "Includes header files in the program.",
"advantage": "Enables modular and reusable code.",
"application": "Used to access standard or custom libraries.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n cout << "Included!";\n return 0;\n}'
},
"13. using": {
"summary": "Simplifies access to namespaces.",
"advantage": "Avoids repetitive namespace qualifiers.",
"application": "Used to shorten code and improve readability.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n cout << "No need for std::cout";\n return 0;\n}'
},
"14. return": {
"summary": "Exits a function and optionally returns a value.",
"advantage": "Controls function output and flow.",
"application": "Used in all functions to signal completion.",
"demo": 'int add(int a, int b) {\n return a + b;\n}\n#include <iostream>\nusing namespace std;\nint main() {\n cout << add(2, 3);\n return 0;\n}'
},
"15. int": {
"summary": "Declares an integer variable.",
"advantage": "Efficient and widely used.",
"application": "Used in counters, indexing, and math.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int x = 5;\n cout << x;\n return 0;\n}'
},
"16. float": {
"summary": "Declares a floating-point variable.",
"advantage": "Supports decimal precision.",
"application": "Used in scientific and financial calculations.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n float pi = 3.14;\n cout << pi;\n return 0;\n}'
},
"17. double": {
"summary": "Declares a double-precision float.",
"advantage": "Higher precision than float.",
"application": "Used in high-accuracy computations.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n double g = 9.80665;\n cout << g;\n return 0;\n}'
},
"18. char": {
"summary": "Declares a single character variable.",
"advantage": "Efficient for storing characters.",
"application": "Used in strings and ASCII manipulation.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n char grade = \'A\';\n cout << grade;\n return 0;\n}'
},
"19. string": {
"summary": "Represents a sequence of characters.",
"advantage": "Flexible and easy to manipulate.",
"application": "Used in text processing and input.",
"demo": '#include <iostream>\n#include <string>\nusing namespace std;\nint main() {\n string name = "Satish";\n cout << name;\n return 0;\n}'
},
"20. bool": {
"summary": "Stores true or false values.",
"advantage": "Essential for logic and conditions.",
"application": "Used in control flow and flags.",
"demo": '#include <iostream>\nusing namespace std;\nbool isEven(int x) {\n return x % 2 == 0;\n}\nint main() {\n cout << isEven(4);\n return 0;\n}'
},
# โ
Entries 21โ50 continue below...
"21. vector": {
"summary": "Dynamic array from the STL.",
"advantage": "Resizable and efficient.",
"application": "Used in data storage and manipulation.",
"demo": '#include <iostream>\n#include <vector>\nusing namespace std;\nint main() {\n vector<int> v = {1, 2, 3};\n v.push_back(4);\n cout << v[3];\n return 0;\n}'
},
"22. map": {
"summary": "Associative container storing key-value pairs.",
"advantage": "Fast lookup and ordered keys.",
"application": "Used in dictionaries and indexing.",
"demo": '#include <iostream>\n#include <map>\nusing namespace std;\nint main() {\n map<string, int> ages;\n ages["Satish"] = 30;\n cout << ages["Satish"];\n return 0;\n}'
},
"23. set": {
"summary": "Stores unique elements in sorted order.",
"advantage": "Automatic duplicate removal.",
"application": "Used in membership tests and filtering.",
"demo": '#include <iostream>\n#include <set>\nusing namespace std;\nint main() {\n set<int> s = {1, 2, 2, 3};\n cout << s.size();\n return 0;\n}'
},
"24. stack": {
"summary": "LIFO data structure from STL.",
"advantage": "Efficient push/pop operations.",
"application": "Used in recursion and parsing.",
"demo": '#include <iostream>\n#include <stack>\nusing namespace std;\nint main() {\n stack<int> s;\n s.push(10);\n cout << s.top();\n return 0;\n}'
},
"25. queue": {
"summary": "FIFO data structure from STL.",
"advantage": "Efficient enqueue/dequeue.",
"application": "Used in scheduling and buffering.",
"demo": '#include <iostream>\n#include <queue>\nusing namespace std;\nint main() {\n queue<int> q;\n q.push(5);\n cout << q.front();\n return 0;\n}'
},
"26. priority_queue": {
"summary": "Heap-based queue for prioritized elements.",
"advantage": "Fast access to largest element.",
"application": "Used in algorithms like Dijkstraโs.",
"demo": '#include <iostream>\n#include <queue>\nusing namespace std;\nint main() {\n priority_queue<int> pq;\n pq.push(3);\n pq.push(5);\n cout << pq.top();\n return 0;\n}'
},
"27. auto": {
"summary": "Automatically deduces variable type.",
"advantage": "Reduces verbosity and errors.",
"application": "Used in loops and templates.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n auto x = 42;\n cout << x;\n return 0;\n}'
},
"28. nullptr": {
"summary": "Represents a null pointer.",
"advantage": "Type-safe replacement for NULL.",
"application": "Used in pointer initialization.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int* p = nullptr;\n cout << (p == nullptr);\n return 0;\n}'
},
"29. new": {
"summary": "Allocates memory dynamically.",
"advantage": "Flexible memory management.",
"application": "Used in heap allocation.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int* p = new int(5);\n cout << *p;\n delete p;\n return 0;\n}'
},
"30. delete": {
"summary": "Frees dynamically allocated memory.",
"advantage": "Prevents memory leaks.",
"application": "Used in cleanup and destructors.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n int* p = new int;\n delete p;\n return 0;\n}'
},
"31. const": {
"summary": "Declares immutable variables.",
"advantage": "Improves safety and clarity.",
"application": "Used in parameters and globals.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n const int x = 10;\n cout << x;\n return 0;\n}'
},
"32. static": {
"summary": "Preserves variable state across calls.",
"advantage": "Useful for counters and caching.",
"application": "Used in functions and classes.",
"demo": '#include <iostream>\nusing namespace std;\nvoid counter() {\n static int count = 0;\n cout << ++count << "\\n";\n}\nint main() {\n counter(); counter();\n return 0;\n}'
},
"33. enum": {
"summary": "Defines named constants.",
"advantage": "Improves readability and safety.",
"application": "Used in states and modes.",
"demo": '#include <iostream>\nusing namespace std;\nenum Color { RED, GREEN, BLUE };\nint main() {\n Color c = GREEN;\n cout << c;\n return 0;\n}'
},
"34. typedef": {
"summary": "Creates type aliases.",
"advantage": "Simplifies complex types.",
"application": "Used in readability and portability.",
"demo": '#include <iostream>\ntypedef unsigned int uint;\nusing namespace std;\nint main() {\n uint x = 100;\n cout << x;\n return 0;\n}'
},
"35. template": {
"summary": "Defines generic functions or classes.",
"advantage": "Supports type-independent code.",
"application": "Used in STL and reusable libraries.",
"demo": '#include <iostream>\ntemplate <typename T>\nT add(T a, T b) { return a + b; }\nusing namespace std;\nint main() {\n cout << add(2, 3);\n return 0;\n}'
},
"36. try-catch": {
"summary": "Handles exceptions gracefully.",
"advantage": "Improves robustness.",
"application": "Used in error handling.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n try {\n throw 404;\n } catch (int e) {\n cout << "Error: " << e;\n }\n return 0;\n}'
},
"37. throw": {
"summary": "Raises an exception.",
"advantage": "Signals error conditions.",
"application": "Used in validation and APIs.",
"demo": '#include <iostream>\nusing namespace std;\nvoid fail() {\n throw "Failure";\n}\nint main() {\n try { fail(); }\n catch (const char* msg) { cout << msg; }\n return 0;\n}'
},
"38. friend": {
"summary": "Grants access to private members.",
"advantage": "Supports tight coupling.",
"application": "Used in operator overloading.",
"demo": '#include <iostream>\nusing namespace std;\nclass A {\n int x = 42;\n friend void show(A);\n};\nvoid show(A a) { cout << a.x; }\nint main() {\n A obj;\n show(obj);\n return 0;\n}'
},
"39. this": {
"summary": "Pointer to the current object.",
"advantage": "Clarifies member access.",
"application": "Used in setters and chaining.",
"demo": '#include <iostream>\nusing namespace std;\nclass A {\n int x;\npublic:\n void set(int x) { this->x = x; }\n void show() { cout << x; }\n};\nint main() {\n A a;\n a.set(5);\n a.show();\n return 0;\n}'
},
"40. operator overloading": {
"summary": "Defines custom behavior for operators.",
"advantage": "Improves class usability.",
"application": "Used in math and containers.",
"demo": '#include <iostream>\nusing namespace std;\nclass Point {\n int x;\npublic:\n Point(int val) : x(val) {}\n Point operator+(Point p) { return Point(x + p.x); }\n void show() { cout << x; }\n};\nint main() {\n Point a(3), b(4);\n Point c = a + b;\n c.show();\n return 0;\n}'
},
"41. virtual": {
"summary": "Allows method overriding in derived classes.",
"advantage": "Supports polymorphism.",
"application": "Used in base class interfaces.",
"demo": '#include <iostream>\nusing namespace std;\nclass Base {\npublic:\n virtual void show() { cout << "Base"; }\n};\nclass Derived : public Base {\npublic:\n void show() override { cout << "Derived"; }\n};\nint main() {\n Base* b = new Derived();\n b->show();\n delete b;\n return 0;\n}'
},
"42. override": {
"summary": "Indicates a method overrides a base class method.",
"advantage": "Improves code safety and clarity.",
"application": "Used in polymorphic hierarchies.",
"demo": '#include <iostream>\nusing namespace std;\nclass Base {\npublic:\n virtual void show() {}\n};\nclass Derived : public Base {\npublic:\n void show() override { cout << "Overridden"; }\n};\nint main() {\n Derived d;\n d.show();\n return 0;\n}'
},
"43. public": {
"summary": "Specifies accessible members.",
"advantage": "Allows external access.",
"application": "Used in class interfaces.",
"demo": '#include <iostream>\nusing namespace std;\nclass A {\npublic:\n int x = 10;\n};\nint main() {\n A a;\n cout << a.x;\n return 0;\n}'
},
"44. private": {
"summary": "Restricts access to members.",
"advantage": "Encapsulates internal state.",
"application": "Used in data hiding.",
"demo": '#include <iostream>\nusing namespace std;\nclass A {\nprivate:\n int x = 42;\npublic:\n int getX() { return x; }\n};\nint main() {\n A a;\n cout << a.getX();\n return 0;\n}'
},
"45. protected": {
"summary": "Accessible in derived classes but not outside.",
"advantage": "Supports inheritance with encapsulation.",
"application": "Used in class hierarchies.",
"demo": '#include <iostream>\nusing namespace std;\nclass Base {\nprotected:\n int x = 5;\n};\nclass Derived : public Base {\npublic:\n void show() { cout << x; }\n};\nint main() {\n Derived d;\n d.show();\n return 0;\n}'
},
"46. inline": {
"summary": "Suggests function expansion at call site.",
"advantage": "Reduces function call overhead.",
"application": "Used in small utility functions.",
"demo": '#include <iostream>\nusing namespace std;\ninline int square(int x) { return x * x; }\nint main() {\n cout << square(4);\n return 0;\n}'
},
"47. extern": {
"summary": "Declares a variable defined elsewhere.",
"advantage": "Supports cross-file linkage.",
"application": "Used in multi-file programs.",
"demo": '// file1.cpp\nint x = 10;\n\n// file2.cpp\nextern int x;\n#include <iostream>\nusing namespace std;\nint main() {\n cout << x;\n return 0;\n}'
},
"48. goto": {
"summary": "Transfers control to a labeled statement.",
"advantage": "Simple but discouraged.",
"application": "Used in legacy or low-level code.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n goto skip;\n cout << "This won\'t print";\nskip:\n cout << "Jumped here";\n return 0;\n}'
},
"49. break": {
"summary": "Exits a loop or switch early.",
"advantage": "Improves control flow.",
"application": "Used in loop termination.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n for (int i = 0; i < 5; i++) {\n if (i == 3) break;\n cout << i << "\\n";\n }\n return 0;\n}'
},
"50. continue": {
"summary": "Skips to the next loop iteration.",
"advantage": "Avoids nested conditions.",
"application": "Used in filtering logic.",
"demo": '#include <iostream>\nusing namespace std;\nint main() {\n for (int i = 0; i < 5; i++) {\n if (i == 2) continue;\n cout << i << "\\n";\n }\n return 0;\n}'
}
}
# ๐ง Entries 11โ50 continue below.
# ๐ Auto-generated entries 6โ50 below
# ๐๏ธ Widgets
cpp_dropdown = widgets.Dropdown(
options=list(cpp_commands.keys()),
description="๐ง C++ Command:",
style={'description_width': '160px'},
layout=widgets.Layout(width='600px')
)
cpp_output = widgets.Output()
def show_cpp_command(change):
cpp_output.clear_output()
with cpp_output:
cmd = change.new
data = cpp_commands[cmd]
display(Markdown(f"### ๐ก Command: `{cmd}`"))
display(Markdown(f"**Summary**: {data['summary']}"))
display(Markdown(f"**Advantage**: {data['advantage']}"))
display(Markdown(f"**Application**: {data['application']}"))
display(Markdown("**๐งช Demonstration Code:**"))
display(Code(data['demo'], language='cpp'))
# โ
Attach listener and trigger initial display
cpp_dropdown.observe(show_cpp_command, names='value')
cpp_dropdown.value = list(cpp_commands.keys())[0]
# ๐ Display UI
display(widgets.VBox([cpp_dropdown, cpp_output]))
## C sharp
import ipywidgets as widgets
from IPython.display import display, Markdown, Code
# ๐ Python Commands Dictionary (50 total)
csharp_commands = {
"1. Console.WriteLine()": {
"summary": "Prints output to the console.",
"advantage": "Simple and widely used for debugging.",
"application": "Used in CLI apps and teaching.",
"demo": 'Console.WriteLine("Hello, world!");'
},
"2. Console.ReadLine()": {
"summary": "Reads input from the user.",
"advantage": "Interactive and flexible.",
"application": "Used in quizzes and input-driven apps.",
"demo": 'string name = Console.ReadLine();\nConsole.WriteLine("Hello " + name);'
},
"3. int": {
"summary": "Declares an integer variable.",
"advantage": "Efficient for whole numbers.",
"application": "Used in counters and math.",
"demo": 'int x = 5;\nConsole.WriteLine(x);'
},
"4. string": {
"summary": "Represents a sequence of characters.",
"advantage": "Flexible and easy to manipulate.",
"application": "Used in text processing.",
"demo": 'string msg = "Welcome";\nConsole.WriteLine(msg);'
},
"5. bool": {
"summary": "Stores true or false values.",
"advantage": "Essential for logic and conditions.",
"application": "Used in control flow.",
"demo": 'bool isReady = true;\nConsole.WriteLine(isReady);'
},
"6. if": {
"summary": "Executes code conditionally.",
"advantage": "Core control structure.",
"application": "Used in decision-making.",
"demo": 'int score = 90;\nif (score > 80) Console.WriteLine("Great!");'
},
"7. else": {
"summary": "Provides alternative execution path.",
"advantage": "Complements if statements.",
"application": "Used in branching logic.",
"demo": 'int score = 60;\nif (score > 80) Console.WriteLine("Great!");\nelse Console.WriteLine("Keep trying!");'
},
"8. switch": {
"summary": "Selects code to execute based on a value.",
"advantage": "Cleaner than multiple if-else blocks.",
"application": "Used in menu systems.",
"demo": 'int choice = 2;\nswitch (choice) {\n case 1: Console.WriteLine("One"); break;\n case 2: Console.WriteLine("Two"); break;\n default: Console.WriteLine("Other"); break;\n}'
},
"9. for": {
"summary": "Loops with a counter.",
"advantage": "Compact and readable.",
"application": "Used in iteration and arrays.",
"demo": 'for (int i = 0; i < 3; i++) {\n Console.WriteLine(i);\n}'
},
"10. while": {
"summary": "Repeats code while a condition is true.",
"advantage": "Flexible for unknown iteration counts.",
"application": "Used in input validation.",
"demo": 'int i = 0;\nwhile (i < 3) {\n Console.WriteLine(i);\n i++;\n}'
},
"11. do-while": {
"summary": "Executes code at least once.",
"advantage": "Ensures one-time execution.",
"application": "Used in menus and retries.",
"demo": 'int i = 0;\ndo {\n Console.WriteLine(i);\n i++;\n} while (i < 3);'
},
"12. List<T>": {
"summary": "Generic dynamic array.",
"advantage": "Resizable and type-safe.",
"application": "Used in collections.",
"demo": 'List<int> nums = new List<int> {1, 2, 3};\nnums.Add(4);\nConsole.WriteLine(nums[3]);'
},
"13. Dictionary<TKey, TValue>": {
"summary": "Stores key-value pairs.",
"advantage": "Fast lookup.",
"application": "Used in mappings and indexes.",
"demo": 'Dictionary<string, int> ages = new Dictionary<string, int>();\nages["Satish"] = 30;\nConsole.WriteLine(ages["Satish"]);'
},
"14. class": {
"summary": "Defines a blueprint for objects.",
"advantage": "Encapsulates data and behavior.",
"application": "Used in OOP design.",
"demo": 'class Person {\n public string Name;\n public void Greet() {\n Console.WriteLine("Hello " + Name);\n }\n}'
},
"15. object": {
"summary": "Base type for all classes.",
"advantage": "Universal reference type.",
"application": "Used in polymorphism.",
"demo": 'object x = "Satish";\nConsole.WriteLine(x);'
},
"16. static": {
"summary": "Belongs to the class, not instance.",
"advantage": "Shared across all instances.",
"application": "Used in utility methods.",
"demo": 'class Math {\n public static int Square(int x) {\n return x * x;\n }\n}\nConsole.WriteLine(Math.Square(4));'
},
"17. new": {
"summary": "Creates an object instance.",
"advantage": "Allocates memory and initializes.",
"application": "Used in object creation.",
"demo": 'Person p = new Person();\np.Name = "Satish";\np.Greet();'
},
"18. null": {
"summary": "Represents no value or object.",
"advantage": "Used in optional references.",
"application": "Used in initialization and checks.",
"demo": 'string name = null;\nif (name == null) Console.WriteLine("No name");'
},
"19. var": {
"summary": "Infers variable type.",
"advantage": "Reduces verbosity.",
"application": "Used in LINQ and loops.",
"demo": 'var x = 42;\nConsole.WriteLine(x);'
},
"20. try-catch": {
"summary": "Handles exceptions.",
"advantage": "Improves robustness.",
"application": "Used in error handling.",
"demo": 'try {\n int x = int.Parse("abc");\n} catch (Exception e) {\n Console.WriteLine("Error: " + e.Message);\n}'
},
"21. throw": {
"summary": "Raises an exception.",
"advantage": "Signals error conditions.",
"application": "Used in validation.",
"demo": 'throw new Exception("Something went wrong");'
},
"22. using": {
"summary": "Manages resource disposal.",
"advantage": "Ensures cleanup.",
"application": "Used with files and streams.",
"demo": 'using (StreamReader sr = new StreamReader("file.txt")) {\n Console.WriteLine(sr.ReadToEnd());\n}'
},
"23. override": {
"summary": "Overrides base class method.",
"advantage": "Supports polymorphism.",
"application": "Used in inheritance.",
"demo": 'class Base {\n public virtual void Show() { Console.WriteLine("Base"); }\n}\nclass Derived : Base {\n public override void Show() { Console.WriteLine("Derived"); }\n}'
},
"24. interface": {
"summary": "Defines a contract for classes.",
"advantage": "Supports abstraction.",
"application": "Used in design patterns.",
"demo": 'interface IGreet {\n void SayHello();\n}\nclass Person : IGreet {\n public void SayHello() { Console.WriteLine("Hi!"); }\n}'
},
"25. foreach": {
"summar": "Iterates over collections.",
"advantage": "Simplifies iteration.",
"application": "Used in arrays and lists.",
"demo": 'int[] nums = {1, 2, 3};\nforeach (int n in nums) {\n Console.WriteLine(n);\n}'
},
"26. class inheritance": {
"summary": "Allows one class to inherit from another.",
"advantage": "Promotes code reuse.",
"application": "Used in OOP hierarchies.",
"demo": 'class Animal {\n public void Speak() { Console.WriteLine("Animal sound"); }\n}\nclass Dog : Animal {}\nDog d = new Dog();\nd.Speak();'
},
"27. abstract class": {
"summary": "Defines a base class with incomplete implementation.",
"advantage": "Enforces structure in derived classes.",
"application": "Used in frameworks and APIs.",
"demo": 'abstract class Shape {\n public abstract double Area();\n}\nclass Circle : Shape {\n public double Radius;\n public override double Area() => Math.PI * Radius * Radius;\n}'
},
"28. sealed class": {
"summary": "Prevents further inheritance.",
"advantage": "Improves security and performance.",
"application": "Used in utility classes.",
"demo": 'sealed class Logger {\n public void Log(string msg) { Console.WriteLine(msg); }\n}'
},
"29. enum": {
"summary": "Defines named constants.",
"advantage": "Improves readability and safety.",
"application": "Used in states and modes.",
"demo": 'enum Day { Sunday, Monday, Tuesday }\nDay today = Day.Monday;\nConsole.WriteLine(today);'
},
"30. nullable types": {
"summary": "Allows value types to hold null.",
"advantage": "Supports optional values.",
"application": "Used in databases and APIs.",
"demo": 'int? age = null;\nif (!age.HasValue) Console.WriteLine("No age");'
},
"31. lambda expression": {
"summary": "Defines anonymous functions.",
"advantage": "Concise and expressive.",
"application": "Used in LINQ and delegates.",
"demo": 'Func<int, int> square = x => x * x;\nConsole.WriteLine(square(5));'
},
"32. delegate": {
"summary": "References a method.",
"advantage": "Supports callbacks.",
"application": "Used in event handling.",
"demo": 'delegate void Greet(string name);\nGreet g = n => Console.WriteLine("Hello " + n);\ng("Satish");'
},
"33. event": {
"summary": "Defines a notification mechanism.",
"advantage": "Supports decoupled communication.",
"application": "Used in UI and system hooks.",
"demo": 'event Action OnClick;\nOnClick += () => Console.WriteLine("Clicked!");\nOnClick();'
},
"34. properties": {
"summary": "Encapsulates fields with accessors.",
"advantage": "Improves encapsulation.",
"application": "Used in data models.",
"demo": 'class Person {\n public string Name { get; set; }\n}\nPerson p = new Person { Name = "Satish" };\nConsole.WriteLine(p.Name);'
},
"35. indexer": {
"summary": "Allows object access via index.",
"advantage": "Improves usability.",
"application": "Used in custom collections.",
"demo": 'class MyList {\n int[] data = {1, 2, 3};\n public int this[int i] => data[i];\n}\nMyList list = new MyList();\nConsole.WriteLine(list[1]);'
},
"36. extension method": {
"summary": "Adds methods to existing types.",
"advantage": "Improves modularity.",
"application": "Used in LINQ and helpers.",
"demo": 'static class Extensions {\n public static int Square(this int x) => x * x;\n}\nConsole.WriteLine(4.Square());'
},
"37. async": {
"summary": "Marks a method as asynchronous.",
"advantage": "Improves responsiveness.",
"application": "Used in I/O and UI apps.",
"demo": 'async Task LoadData() {\n await Task.Delay(1000);\n Console.WriteLine("Loaded");\n}'
},
"38. await": {
"summary": "Waits for an async operation.",
"advantage": "Non-blocking execution.",
"application": "Used in async workflows.",
"demo": 'await Task.Delay(500);\nConsole.WriteLine("Done");'
},
"39. Task": {
"summary": "Represents an asynchronous operation.",
"advantage": "Supports concurrency.",
"application": "Used in parallel processing.",
"demo": 'Task t = Task.Run(() => Console.WriteLine("Running"));\nt.Wait();'
},
"40. operator overloading": {
"summary": "Defines custom behavior for operators.",
"advantage": "Improves class usability.",
"application": "Used in math and containers.",
"demo": '#include <iostream>\nusing namespace std;\nclass Point {\n int x;\npublic:\n Point(int val) : x(val) {}\n Point operator+(Point p) { return Point(x + p.x); }\n void show() { cout << x; }\n};\nint main() {\n Point a(3), b(4);\n Point c = a + b;\n c.show();\n return 0;\n}'
},
"41. try-finally": {
"summary": "Executes cleanup code.",
"advantage": "Ensures resource release.",
"application": "Used in file and stream handling.",
"demo": 'try {\n Console.WriteLine("Try");\n} finally {\n Console.WriteLine("Cleanup");\n}'
},
"42. is": {
"summary": "Checks type compatibility.",
"advantage": "Supports safe casting.",
"application": "Used in polymorphism.",
"demo": 'object obj = "Satish";\nif (obj is string) Console.WriteLine("It\'s a string");'
},
"43. as": {
"summary": "Performs safe casting.",
"advantage": "Avoids exceptions.",
"application": "Used in type conversion.",
"demo": 'object obj = "Satish";\nstring name = obj as string;\nConsole.WriteLine(name);'
},
"44. typeof": {
"summary": "Gets the type object.",
"advantage": "Supports reflection.",
"application": "Used in metadata access.",
"demo": 'Console.WriteLine(typeof(int));'
},
"45. nameof": {
"summary": "Gets the name of a symbol.",
"advantage": "Improves refactoring safety.",
"application": "Used in logging and validation.",
"demo": 'string name = nameof(Console);\nConsole.WriteLine(name);'
},
"46. Environment": {
"summary": "Provides system info.",
"advantage": "Accesses runtime data.",
"application": "Used in diagnostics.",
"demo": 'Console.WriteLine(Environment.OSVersion);'
},
"47. File": {
"summary": "Performs file operations.",
"advantage": "Simplifies I/O.",
"application": "Used in reading/writing files.",
"demo": 'File.WriteAllText("test.txt", "Hello");\nConsole.WriteLine(File.ReadAllText("test.txt"));'
},
"48. DateTime": {
"summary": "Represents date and time.",
"advantage": "Rich time manipulation.",
"application": "Used in scheduling and logs.",
"demo": 'DateTime now = DateTime.Now;\nConsole.WriteLine(now);'
},
"49. Regex": {
"summary": "Performs pattern matching.",
"advantage": "Flexible string validation.",
"application": "Used in input validation.",
"demo": 'Regex r = new Regex(@"\\d+");\nConsole.WriteLine(r.IsMatch("123"));'
},
"50. LINQ": {
"summary": "Queries collections using SQL-like syntax.",
"advantage": "Concise and powerful.",
"application": "Used in data filtering and transformation.",
"demo": 'int[] nums = {1, 2, 3, 4};\nvar evens = nums.Where(n => n % 2 == 0);\nforeach (var n in evens) Console.WriteLine(n);'
}
}
# ๐๏ธ Widgets
csharp_dropdown = widgets.Dropdown(
options=list(csharp_commands.keys()),
description="๐ง C# Command:",
style={'description_width': '160px'},
layout=widgets.Layout(width='600px')
)
csharp_output = widgets.Output()
def show_csharp_command(change):
cpp_output.clear_output()
with cpp_output:
cmd = change.new
data = cshaprp_commands[cmd]
display(Markdown(f"### ๐ก Command: `{cmd}`"))
display(Markdown(f"**Summary**: {data['summary']}"))
display(Markdown(f"**Advantage**: {data['advantage']}"))
display(Markdown(f"**Application**: {data['application']}"))
display(Markdown("**๐งช Demonstration Code:**"))
display(Code(data['demo'], language='cpp'))
# โ
Attach listener and trigger initial display
csharp_dropdown.observe(show_csharp_command, names='value')
csharp_dropdown.value = list(csharp_commands.keys())[0]
# ๐ Display UI
display(widgets.VBox([csharp_dropdown, csharp_output]))