CodeCatch
User since Oct 15, 2022
155 Posts
Recent Posts
interface Task {id: number;title: string;completed: boolean;}class TaskManager {private tasks: Task[] = [];constructor() {}addTask(title: string) {const taskId = this.tasks.length + 1;const task: Task = {id: taskId,title,completed: false,};this.tasks.push(task);}markTaskAsComplete(taskId: number) {const task = this.tasks.find((task) => task.id === taskId);if (task) {task.completed = true;}}markTaskAsIncomplete(taskId: number) {const task = this.tasks.find((task) => task.id === taskId);if (task) {task.completed = false;}}listTasks() {console.log('Tasks:');this.tasks.forEach((task) => {console.log(`${task.id}. [${task.completed ? 'X' : ' '}] ${task.title}`);});}}// Example usage:const taskManager = new TaskManager();taskManager.addTask('Buy groceries');taskManager.addTask('Pay bills');taskManager.addTask('Clean the house');taskManager.listTasks();// Output:// Tasks:// 1. [ ] Buy groceries// 2. [ ] Pay bills// 3. [ ] Clean the house
bytes_data = b'Hello, World!'string_data = bytes_data.decode('utf-8')print("String:", string_data)
def calculate_values():value1 = 10value2 = 20return value1, value2result1, result2 = calculate_values()print("Result 1:", result1)print("Result 2:", result2)
filename = "data.txt"with open(filename, "r") as file:file_contents = file.readlines()file_contents = [line.strip() for line in file_contents]print("File contents:")for line in file_contents:print(line)
from colorama import init, Fore# Initialize coloramainit()print(Fore.RED + "This text is in red color.")print(Fore.GREEN + "This text is in green color.")print(Fore.BLUE + "This text is in blue color.")# Reset coloramaprint(Fore.RESET + "This text is back to the default color.")
filename = "data.txt"data = "Hello, World!"with open(filename, "a") as file:file.write(data)
Post Statistics
Posts
No Posts Found
It looks like CodeCatch has no public posts
Likes
Please Log In
You must be authenticated to view a user's likes
Profile Privacy
Multi-Factor Authentication
Multi-Factor Authentication (MFA) is an authentication method that requires you to provide two or more verification factors to gain access to your account. In addition to username and password, MFA requires you to verify your email on every login, which decreases the likelihood of someone stealing your account.
Change Password
Identity Color
Changes the color of your profile icon and cursor highlight in the live code editor. You and other users will be able to view this change.
Delete Account
Deleting your account is permanent. All data associated with your account will be lost.