Here's some HTML:
<!DOCTYPE html> <html> <head> <title>Complex HTML Example</title> <style> body { font-family: Arial, sans-serif; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 10px; } th { background-color: #f2f2f2; } .navigation { list-style-type: none; margin: 0; padding: 0; } .navigation li { display: inline; margin-right: 10px; } .navigation a { text-decoration: none; color: blue; } </style> </head> <body> <h2>Complex HTML Form</h2> <form id="myForm"> <label for="fname">First name:</label><br> <input type="text" id="fname" name="fname"><br> <label for="lname">Last name:</label><br> <input type="text" id="lname" name="lname"><br><br> <input type="button" value="Submit" onclick="submitForm()"> </form> <h2>Data Table</h2> <table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> </tr> <tr> <td>John</td> <td>Doe</td> <td>john@example.com</td> </tr> <tr> <td>Jane</td> <td>Doe</td> <td>jane@example.com</td> </tr> </table> <h2>Navigation</h2> <ul class="navigation"> <li><a href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> <script> function submitForm() { var fname = document.getElementById("fname").value; var lname = document.getElementById("lname").value; alert("Hello " + fname + " " + lname + "!"); } </script> </body> </html>
CSS sample:
/* Basic Reset */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Arial', sans-serif; line-height: 1.6; background-color: #f4f4f4; padding: 20px; } .container { max-width: 1100px; margin: auto; padding: 20px; overflow: hidden; } /* Navigation Styles */ .navbar { display: flex; justify-content: space-between; align-items: center; background: #333; color: #fff; padding: 10px; } .navbar a { color: #fff; text-decoration: none; padding: 10px; } /* Card Styles */ .card { background: #fff; margin-bottom: 20px; padding: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } /* Button Styles */ .button { display: inline-block; background: #007bff; color: #fff; padding: 10px 15px; border: none; cursor: pointer; border-radius: 5px; transition: background 0.3s ease; } .button:hover { background: #0056b3; } /* Form Styles */ .form-input { margin-bottom: 20px; } .form-input label { display: block; margin-bottom: 5px; } .form-input input[type="text"], .form-input input[type="email"], .form-input input[type="password"] { width: 100%; padding: 10px; border-radius: 5px; border: 1px solid #ccc; } /* Animations */ @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .fadeIn { animation: fadeIn 2s ease-in; } /* Responsive Design */ @media (max-width: 768px) { .navbar { flex-direction: column; } .card { margin: 0 0 20px 0; } }
JS
async function fetchUserData(userId) { try { const response = await fetch(`https://api.example.com/users/${userId}`); if (!response.ok) { throw new Error('Failed to fetch user data'); } const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); } } fetchUserData(1);
Python
import pandas as pd import matplotlib.pyplot as plt # Load a dataset df = pd.read_csv('data.csv') # Data preprocessing df.dropna(inplace=True) df['Date'] = pd.to_datetime(df['Date']) df.set_index('Date', inplace=True) # Data analysis monthly_sales = df.resample('M').sum() # Data visualization plt.figure(figsize=(10, 6)) plt.plot(monthly_sales, color='blue', marker='o') plt.title('Monthly Sales Over Time') plt.xlabel('Month') plt.ylabel('Sales') plt.grid(True) plt.show()
Java
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class MultithreadingExample { public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(5); for (int i = 0; i < 10; i++) { Runnable worker = new WorkerThread("" + i); executor.execute(worker); } executor.shutdown(); try { executor.awaitTermination(1, TimeUnit.HOURS); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("All threads completed."); } } class WorkerThread implements Runnable { private String command; public WorkerThread(String s) { this.command = s; } @Override public void run() { System.out.println(Thread.currentThread().getName() + " Start. Command = " + command); processCommand(); System.out.println(Thread.currentThread().getName() + " End."); } private void processCommand() { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } }
C#
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var evenNumbers = from num in numbers where num % 2 == 0 select num; Console.WriteLine("Even numbers:"); foreach (int num in evenNumbers) { Console.WriteLine(num); } } }
C++
#include <iostream> #include <fstream> #include <string> int main() { std::string line; std::ifstream myfile("example.txt"); if (myfile.is_open()) { while (getline(myfile, line)) { std::cout << line << '\n'; } myfile.close(); } else std::cout << "Unable to open file"; std::ofstream myfileOut("example.txt", std::ios_base::app); // Append mode if (myfileOut.is_open()) { myfileOut << "Adding a new line.\n"; myfileOut.close(); } else std::cout << "Unable to open file"; return 0; }
PHP
<?php // Assume a table 'users' with columns 'id', 'name', 'email' $dsn = 'mysql:host=localhost;dbname=testdb'; $user = 'dbuser'; $password = 'dbpass'; try { $pdo = new PDO($dsn, $user, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['name']) && !empty($_POST['email'])) { $sql = "INSERT INTO users (name, email) VALUES (:name, :email)"; $stmt = $pdo->prepare($sql); $stmt->execute([':name' => $_POST['name'], ':email' => $_POST['email']]); echo "User added successfully."; } } catch (PDOException $e) { die("Could not connect to the database $dbname :" . $e->getMessage()); } ?> <form method="post"> Name: <input type="text" name="name"><br> Email: <input type="email" name="email"><br> <input type="submit"> </form>
SWIFT import Foundation struct User: Codable { let id: Int let name: String let email: String } func fetchUserData() { let urlString = "https://example.com/api/users/1" guard let url = URL(string: urlString) else { return } URLSession.shared.dataTask(with: url) { data, response, error in if let error = error { print("Error fetching data: \(error)") return } guard let data = data else { return } do { let user = try JSONDecoder().decode(User.self, from: data) print("User Name: \(user.name), Email: \(user.email)") } catch { print("Error parsing data: \(error)") } }.resume() } fetchUserData()
GO
package main import ( "fmt" "net/http" ) func helloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, Go Web Development!") } func main() { http.HandleFunc("/", helloHandler) fmt.Println("Server starting on port 8080...") if err := http.ListenAndServe(":8080", nil); err != nil { panic(err) } }
RUST
use tokio::task; use reqwest::Error; async fn fetch_url(url: &str) -> Result<(), Error> { let body = reqwest::get(url).await?.text().await?; println!("Body: {:?}", body); Ok(()) } #[tokio::main] async fn main() { let urls = vec![ "http://example.com", "http://example.org", "http://example.net", ]; let tasks: Vec<_> = urls.iter().map(|url| { task::spawn(async move { match fetch_url(url).await { Ok(_) => println!("Successfully fetched {}", url), Err(e) => println!("Error fetching {}: {}", url, e), } }) }).collect(); for task in tasks { let _ = task.await; } }
And those are the types!
Thanks for reading!