Introduction to Python
Python is a versatile, high-level programming language known for its readability and ease of use. It is widely used in web development, data analysis, artificial intelligence, scientific computing, and more.
Variables and Data Types
Variables in Python are used to store data. Python supports various data types, such as integers, floats, strings, lists, tuples, and dictionaries.
# Example of variables in Python
name = "QuestGen"
age = 25
is_active = True
Control Structures
Python supports conditional statements and loops to control the flow of the program.
# Example of if-else statement
if age > 18:
print("You are an adult.")
else:
print("You are a minor.")
Functions
Functions in Python are blocks of reusable code. They make programs modular and easy to debug.
# Example of a Python function
def greet(name):
return f"Hello, {name}!"
print(greet("QuestGen"))
Object-Oriented Programming
Python supports object-oriented programming (OOP) with classes and objects.
# Example of a Python class
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
person = Person("QuestGen", 25)
print(person.name)
Modules and Libraries
Python has a rich ecosystem of modules and libraries, such as NumPy, Pandas, and Matplotlib, to simplify various tasks.
# Example of using a module
import math
print(math.sqrt(16))
Introduction to JavaScript
JavaScript is a lightweight, interpreted programming language. It is one of the core technologies of the web, used for creating interactive and dynamic web pages.
Variables and Data Types
JavaScript variables store data that can be used and manipulated. JavaScript supports data types like strings, numbers, booleans, arrays, and objects.
// Example of variables in JavaScript
let name = "QuestGen";
let age = 25;
let isActive = true;
Control Structures
JavaScript provides control structures like if-else statements, loops, and switch cases to control the flow of the program.
// Example of if-else statement
if (age > 18) {
console.log("You are an adult.");
} else {
console.log("You are a minor.");
}
Functions
Functions in JavaScript are reusable blocks of code that perform a specific task.
// Example of a JavaScript function
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("QuestGen"));
Object-Oriented Programming
JavaScript supports object-oriented programming through prototypes and ES6 classes.
// Example of a JavaScript class
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
let person = new Person("QuestGen", 25);
console.log(person.name);
Modules and Libraries
JavaScript has many libraries and frameworks, such as React, Angular, and Vue.js, to enhance development.
// Example of importing a module
import { sqrt } from "mathjs";
console.log(sqrt(16));
Introduction to Java
Java is a versatile, object-oriented programming language widely used for developing robust applications, from desktop to enterprise-level systems.
Variables and Data Types
Java variables are used to store data. Java supports primitive data types like int, float, char, and boolean, as well as non-primitive types like String and Arrays.
// Example of variables in Java
String name = "QuestGen";
int age = 25;
boolean isActive = true;
Control Structures
Java provides control structures like if-else, switch cases, and loops to control the flow of the program.
// Example of if-else statement in Java
if (age > 18) {
System.out.println("You are an adult.");
} else {
System.out.println("You are a minor.");
}
Functions
Functions (or methods) in Java are blocks of code that perform specific tasks.
// Example of a Java method
public static String greet(String name) {
return "Hello, " + name + "!";
}
System.out.println(greet("QuestGen"));
Object-Oriented Programming
Java is built on OOP principles, allowing developers to create classes and objects to model real-world problems.
// Example of a Java class
class Person {
String name;
int age;
Person(String name, int age) {
this.name = name;
this.age = age;
}
}
Person person = new Person("QuestGen", 25);
System.out.println(person.name);
Modules and Libraries
Java offers an extensive ecosystem of libraries and frameworks, including Spring, Hibernate, and JavaFX, to simplify development.
// Example of using a library
import java.util.Scanner;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your name:");
String name = scanner.nextLine();