1) RUBY LANGUAGE MAIN.RB
# puts "Krishna"
# print"Hello world"
# //drawing a shape
# puts " /|"
# puts " / |"
# puts " / |"
# puts " / |"
# puts " /____|"
# Local variables
# character_name = "Tom" # Local variable storing the name "Tom"
# character_age = "30" # Local variable storing the age "30"
# character_home = "Pikachu" # Local variable storing the home "Pikachu"
# puts "There once was a man named #{character_name}." # Outputs: "There once was a man named Tom."
# puts ("He was " + character_age + " years old.") # Outputs: "He was 30 years old."
# puts "Hello, #{character_name}!" # Outputs: "Hello, Tom!"
# puts "Your age is #{character_age}." # Outputs: "Your age is 30."
# puts "Your home is #{character_home}." # Outputs: "Your home is Pikachu."
# Data types
# String: A sequence of characters
# name = "Tom" # Example of a String
# Integer: A whole number
# age = 30 # Example of an Integer
# Float: A number with a decimal point
# height = 5.9 # Example of a Float
# Boolean: Represents true or false values
# is_student = true # Example of a Boolean
# Array: An ordered collection of elements
# fruits = ["apple", "banana", "cherry"] # Example of an Array
# Hash: A collection of key-value pairs (similar to dictionaries in Python)
# person = {name: "Tom", age: 30} # Example of a Hash
# Symbol: A lightweight, immutable string used as identifiers or keys
# status = :active # Example of a Symbol
# Nil: Represents "nothing" or "no value"
# middle_name = nil # Example of Nil
# Range: Represents an interval, a sequence of values
# range = (1..5) # Example of a Range, representing 1 to 5 inclusive
# Time: Represents dates and times
# current_time = Time.now # Example of a Time object, representing the current time
# strings
# Basic String: A sequence of characters enclosed in double or single quotes
# greeting = "Hello, world!" # Example of a basic String using double quotes
# name = 'Tom' # Example of a basic String using single quotes
# String Interpolation: Injecting variables or expressions inside a string
# age = 30
# intro = "My name is #{name} and I am #{age} years old." # Interpolating variables into a String
# Concatenation: Joining two or more strings together
# full_greeting = "Hello, " + name + "!" # Concatenating strings using the + operator
# Multi-line String: A string that spans multiple lines using heredoc syntax
# long_text = <<~TEXT
# This is a multi-line string.
# It can span multiple lines.
# Useful for large blocks of text.
# TEXT
# String Methods: Useful methods for working with strings
# uppercase_name = name.upcase # Converts the string to uppercase: "TOM"
# reversed_name = name.reverse # Reverses the string: "moT"
# length_of_name = name.length # Returns the length of the string: 3
# includes_name = name.include?("T") # Checks if the string includes a specific substring: true
# lowercase_name = name.downcase # Converts the string to lowercase: "tom"
# String Substitution: Replacing part of a string with another string
# corrected_name = "Tim".sub("Tim", "Tom") # Replaces "Tim" with "Tom": "Tom"
# String Splitting: Splitting a string into an array of substrings
# words = "apple,banana,cherry".split(",") # Splits the string into an array: ["apple", "banana", "cherry"]
# String Comparison: Comparing two strings
# is_same_name = name == "Tom" # Checks if the string is equal to "Tom": true
# phrase = "Krishna blogger"
# puts phrase[9]
# Math & Numbers
# puts 5+5
# puts 5-5
# puts 5*5
# puts 5/5
# puts 5%5
# puts 5**5
# puts 5.0/5
# puts 5.0/2
# puts 5.0/2.0
# num = 20
# puts ("my fav num " + num.to_s)
# puts num.abs()
# num = 20.455
# puts num.round()
# num = 30.1
# puts num.ceil()
# num = 30.9
# puts num.floor()
# puts Math.sqrt(25)
# puts Math.log(10)
# Getting User Input
# Example with gets.chomp()
# puts "Enter your name (with chomp):"
# name_with_chomp = gets.chomp() # Removes the newline character
# puts "Hello #{name_with_chomp}","You are cool"
# puts "\n" # Just adding an extra newline for clarity in the output
# # Example with gets (without chomp)
# puts "Enter your name (without chomp):"
# name_without_chomp = gets # Keeps the newline character
# puts "Hello #{name_without_chomp}","You are cool"
# puts "Enter your age: "
# name = gets.chomp()
# puts ("You are " + name + " years old")
# arrays
# friends = Array["sim", "Tom", "Jerry"]
# # 0 1 2
# puts friends[1] # negative series also
# puts friends.include? "karan"
# puts friends.Reverse()
# puts friends.sort()
# Hashes
# states = {
# "NY" => "New York",
# "CA" => "California",
# "AZ" => "Arizona"
# }
# puts states["NY"] # Outputs the value for the key "NY"
# puts states["AZ"] # Outputs the value for the key "AZ"
# states["NY"] = "New York State" # Updates the value for the key "NY"
# puts states["NY"] # Outputs the updated value for "NY"
# states["NJ"] = "New Jersey" # Adds a new key-value pair to the hash
# puts states # Outputs the entire hash
# puts states.keys # Outputs all the keys in the hash
# puts states.values # Outputs all the values in the hash
# puts states.to_a # Converts the hash to an array of key-value pairs
# Methods
# def sayhi
# puts " Hello Blogger"
# end
# puts "Top"
# sayhi
# puts "Bottom"
# def sayhi(name="Krishna", age=19)
# puts ("Hello " + name + " you are " + age.to_s)
# end
# sayhi("Krishna", 19)
# Return Statements
# Find the cube
# def cube(num)
# num * num * num
# end
# puts cube(3)
# if Statements
# ismale = true
# istall = false
# if ismale and istall
# puts "You are a tall male"
# elsif ismale and !istall
# puts "You are a short male"
# elsif !ismale and istall
# puts "You are tall but not male"
# else
# puts "You are not male and not tall"
# end
# if statement (con't)
# def max(num1, num2, num3)
# if num1 >= num2 and num1 >= num3
# return num1
# elsif num2 >= num1 and num2 >= num3
# return num2
# else
# return num3
# end
# end
# puts max(1, 2, 3) #put the highest number in the list
# case Expressions
#if else if ladder
# def get_day_name(day)
# day_name = ""
# case day
# when "mon"
# day_name = "Monday"
# when "tue"
# day_name = "Tuesday"
# when "wed"
# day_name = "Wednesday"
# when "thu"
# day_name = "Thursday"
# when "fri"
# day_name = "Friday"
# when "sat"
# day_name = "Saturday"
# when "sun"
# day_name = "Sunday"
# else
# day_name = "Invalid abbreviation"
# end
# return day_name
# end
# while loop
#1 to 5
# index = 1
# while index <= 5
# puts index
# index += 1
# end
#hello world
# i = 0
# while i < 10 do
# puts "Hello, World!"
# i += 1
# end
# for loops
# friends = ["Jim", "Karen", "Kevin","oscar","kerala"]
# for element in friends
# puts element
# end
# friends.each do |friend|
# puts friend
# end
# for i in 0..5
# puts i
# end
# Exponent method
# def pow(base_num, pow_num)
# result = 1
# pow_num.times do
# result = result * base_num
# end
# return result
# end
# puts pow(2, 3)
# Reading Files
# File.open("test.txt") do |file|
# puts file.readline()
# puts file.readChar()
# for line in file.readlines()
# puts line
# end
# end
#writing files
# File.open("test.txt", "a") do |file|
# file.write("\nOscar, Accounting")
# end
#Clases and Objects
# class Book
# attr_accessor :title, :author, :pages
# def initialize(title, author, pages)
# @title = title
# @author = author
# @pages = pages
# end
# end
# book1 = Book.new("Harry Potter","JK Rowling", 500)
# book2 = Book.new("Lord of the Rings","Tolkien", 700)
# puts book2.title
#Objects Methods
# class Student
# attr_accessor :name, :major, :gpa
# def initialize(name, major, gpa)
# @name = name
# @major = major
# @gpa = gpa
# end
# def has_honors
# if @gpa >= 3.5
# return true
# end
# return false
# end
# end
# student1 = Student.new("Jim", "Business", 3.0)
# student2 = Student.new("Pam", "Art", 2.5)
#InHeritance
# class Chef
# def make_noodles()
# puts "The chef makes noodles"
# end
# def make_potato_chips()
# puts "The chef makes potato chips"
# end
# def make_special_dish()
# puts "The chef makes a burger"
# end
# end
# class ChineseChef < Chef
# def make_special_noodles()
# puts "The chef makes special Chinese noodles"
# end
# end
# # Creating an instance of ChineseChef
# chef = ChineseChef.new()
# # Calling the method from the ChineseChef class
# chef.make_special_noodles()
# # You can also call methods inherited from the Chef class
# chef.make_noodles()
# chef.make_potato_chips()
# chef.make_special_dish()
2)If else in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Person Information</title>
</head>
<body>
<script>
// Function to get user input and perform checks
function getPersonInfo() {
// Collect user input
let firstName = prompt("Enter the person's first name:");
let lastName = prompt("Enter the person's last name:");
let age = parseInt(prompt("Enter the person's age:"), 10);
let isMarried = prompt("Is the person married? (yes/no):").toLowerCase() === 'yes';
// Create person object with user input
let person = {
firstName: firstName,
lastName: lastName,
age: age,
isMarried: isMarried
};
// Perform checks based on the person's age and marital status
if (person.age < 18) {
console.log(person.firstName + " is too young to be married and should be in school.");
} else if (person.age >= 18 && person.age <= 24) {
// For people aged 18 to 24
if (person.age >= 17 && person.age <= 24) {
console.log(person.firstName + " should be in college.");
}
if (person.isMarried) {
console.log(person.firstName + " is an adult and is married.");
} else {
console.log(person.firstName + " is an adult but is not married.");
}
} else if (person.age >= 25) {
// For people aged 25 and above
if (person.isMarried) {
console.log(person.firstName + " is an adult and is married.");
} else {
console.log(person.firstName + " is an adult and not married.");
}
} else {
console.log(person.firstName + " is not in a valid age range.");
}
}
// Call the function to execute the script
getPersonInfo();
</script>
</body>
</html>
3)Loops in js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>loops</title>
</head>
<body>
<script>
// Using while loop to print numbers from 0 to 99
let i = 0;
while (i < 100) {
console.log(i);
i++;
}
// Using while loop to print "hey my bloggers" 100 times
let j = 0;
while (j < 100) {
console.log("hey my bloggers");
j++;
}
// Resetting the variables to use them again
i = 0;
j = 0;
// Using do...while loop to print numbers from 0 to 99
do {
console.log(i);
i++;
} while (i < 100);
// Using do...while loop to print "hey my bloggers" 100 times
do {
console.log("hey my bloggers");
j++;
} while (j < 100);
</script>
</body>
</html>
4)basic js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- Input box where user types -->
<input type="text" id="inputBox" placeholder="Type something...">
<!-- Button to trigger the event -->
<button id="button">Submit</button>
<!-- Output box where the result will be displayed -->
<div id="outputBox"></div>
<script>
// Get the HTML elements by their IDs
let inputBox = document.getElementById("inputBox");
let button = document.getElementById("button");
let outputBox = document.getElementById("outputBox");
console.log(inputBox, button, outputBox);
// Add event listener to the button
button.addEventListener("click", function() {
// Get the value from the input box
let inputValue = inputBox.value;
console.log(inputValue);
// Display the input value in the output box
outputBox.innerHTML = inputValue;
});
</script>
</body>
</html>
5)Gallery.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Image Gallery</title>
<style>
* {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
box-sizing: border-box;
}
body {
background: #191919;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.gallery-wrap {
display: flex;
align-items: center;
}
.gallery {
width: 900px;
display: flex;
overflow-x: scroll;
scroll-behavior: smooth;
}
.gallery div {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 20px;
padding: 10px;
flex: none;
}
.gallery div img {
width: 100%;
filter: grayscale(100%);
transition: transform 0.5s;
}
.gallery::-webkit-scrollbar {
display: none;
}
#backBtn, #nextBtn {
width: 50px;
cursor: pointer;
margin: 0 20px;
user-select: none;
}
.gallery div img:hover {
filter: grayscale(0);
cursor: pointer;
transform: scale(1.1);
}
</style>
</head>
<body>
<div class="gallery-wrap">
<img src="back-arrow.png" id="backBtn">
<div class="gallery">
<div>
<span><img src="image1.jpg" alt="Image 1"></span>
<span><img src="image2.jpg" alt="Image 2"></span>
<span><img src="image3.jpg" alt="Image 3"></span>
<span><img src="image4.jpg" alt="Image 4"></span>
<span><img src="image5.jpg" alt="Image 5"></span>
<span><img src="image6.jpg" alt="Image 6"></span>
<span><img src="image7.jpg" alt="Image 7"></span>
<span><img src="image8.jpg" alt="Image 8"></span>
<span><img src="image9.jpg" alt="Image 9"></span>
</div>
</div>
<img src="next-arrow.png" id="nextBtn">
</div>
<script>
let scrollContainer = document.querySelector('.gallery');
let backBtn = document.getElementById('backBtn');
let nextBtn = document.getElementById('nextBtn');
scrollContainer.addEventListener('wheel', (evt) => {
evt.preventDefault();
scrollContainer.scrollLeft += evt.deltaY;
});
nextBtn.addEventListener('click', () => {
scrollContainer.scrollLeft += scrollContainer.clientWidth;
});
backBtn.addEventListener('click', () => {
scrollContainer.scrollLeft -= scrollContainer.clientWidth;
});
</script>
</body>
</html>
6)ALL STANDARD TIME
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Time Zone Clock</title>
<style>
* {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
box-sizing: border-box;
}
body {
background: linear-gradient(45deg, #08001f, #30197d);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
color: #fff;
text-align: center;
}
.container {
width: 350px;
height: 350px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
border-radius: 15px;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}
.clock {
font-size: 48px;
font-weight: bold;
letter-spacing: 5px;
margin: 20px;
}
select {
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: none;
outline: none;
background: #fff;
color: #000;
}
.container::before,
.container::after {
content: '';
position: absolute;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
animation: rotate 10s infinite linear;
}
.container::before {
width: 250px;
height: 250px;
top: -75px;
left: -75px;
}
.container::after {
width: 200px;
height: 200px;
bottom: -50px;
right: -50px;
}
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="container">
<div class="clock" id="clock">
12:00:00 AM
</div>
<select id="timezone">
<option value="UTC">UTC</option>
<option value="IST">IST (Indian Standard Time)</option>
<option value="PST">PST (Pacific Standard Time)</option>
<option value="CET">CET (Central European Time)</option>
<option value="EST">EST (Eastern Standard Time)</option>
<option value="JST">JST (Japan Standard Time)</option>
<option value="AEST">AEST (Australian Eastern Standard Time)</option>
<!-- Add more time zones as needed -->
</select>
</div>
<script>
function updateClock() {
const now = new Date();
const selectedTimeZone = document.getElementById('timezone').value;
let offset = 0; // default to UTC
let offsetMinutes = 0;
switch (selectedTimeZone) {
case 'IST':
offset = 5; // IST is UTC+5:30
offsetMinutes = 30;
break;
case 'PST':
offset = -8; // PST is UTC-8
break;
case 'CET':
offset = 1; // CET is UTC+1
break;
case 'EST':
offset = -5; // EST is UTC-5
break;
case 'JST':
offset = 9; // JST is UTC+9
break;
case 'AEST':
offset = 10; // AEST is UTC+10
break;
// Add more time zone offsets as needed
}
// Convert current time to UTC
const utcHours = now.getUTCHours();
const utcMinutes = now.getUTCMinutes();
const utcSeconds = now.getUTCSeconds();
// Apply time zone offset
let hours = utcHours + offset;
let minutes = utcMinutes + offsetMinutes;
let seconds = utcSeconds;
if (minutes >= 60) {
hours += Math.floor(minutes / 60);
minutes = minutes % 60;
} else if (minutes < 0) {
hours -= Math.ceil(Math.abs(minutes) / 60);
minutes = (60 + (minutes % 60)) % 60;
}
hours = (hours + 24) % 24;
// Format to 12-hour time with AM/PM
const period = hours >= 12 ? 'PM' : 'AM';
const displayHours = hours % 12 || 12; // the hour '0' should be '12'
// Format the time
const formattedHours = String(displayHours).padStart(2, '0');
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(seconds).padStart(2, '0');
document.getElementById('clock').textContent = `${formattedHours}:${formattedMinutes}:${formattedSeconds} ${period}`;
}
document.getElementById('timezone').addEventListener('change', updateClock);
setInterval(updateClock, 1000);
updateClock();
</script>
</body>
</html>
7)Analog Clock with STANDARD TIME
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Analog Clock with Time Zones</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Courier New', Courier, monospace;
}
body {
background: linear-gradient(45deg, #08001f, #30197d);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
color: #fff;
text-align: center;
}
.clock {
width: 500px;
height: 500px;
border-radius: 50%;
background-color: white;
position: relative;
border: 5px solid #000;
}
.clock .num {
position: absolute;
font-size: 1.5rem;
font-weight: 600;
color: black;
text-align: center;
width: 100%;
}
.clock .num1 { top: 10%; left: 50%; transform: translate(-50%, -50%) rotate(30deg); }
.clock .num2 { top: 25%; left: 80%; transform: translate(-50%, -50%) rotate(60deg); }
.clock .num3 { top: 50%; left: 85%; transform: translate(-50%, -50%) rotate(90deg); }
.clock .num4 { top: 75%; left: 80%; transform: translate(-50%, -50%) rotate(120deg); }
.clock .num5 { top: 90%; left: 50%; transform: translate(-50%, -50%) rotate(150deg); }
.clock .num6 { top: 75%; left: 20%; transform: translate(-50%, -50%) rotate(180deg); }
.clock .num7 { top: 50%; left: 15%; transform: translate(-50%, -50%) rotate(210deg); }
.clock .num8 { top: 25%; left: 20%; transform: translate(-50%, -50%) rotate(240deg); }
.clock .num9 { top: 10%; left: 50%; transform: translate(-50%, -50%) rotate(270deg); }
.clock .num10 { top: 25%; left: 80%; transform: translate(-50%, -50%) rotate(300deg); }
.clock .num11 { top: 50%; left: 85%; transform: translate(-50%, -50%) rotate(330deg); }
.clock .num12 { top: 10%; left: 50%; transform: translate(-50%, -50%) rotate(360deg); }
.clock::after {
content: '';
position: absolute;
background-color: black;
width: 20px;
height: 20px;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
.clock .hand {
--rotation: 0;
position: absolute;
bottom: 50%;
left: 50%;
transform-origin: bottom;
transform: translateX(-50%) rotate(calc(var(--rotation) * 1deg));
}
.clock .sec {
width: 2px;
height: 45%;
background-color: red;
}
.clock .min {
width: 4px;
height: 40%;
background-color: blue;
}
.clock .hr {
width: 8px;
height: 35%;
background-color: green;
}
select {
margin-top: 20px;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: none;
outline: none;
background: #fff;
color: #000;
}
</style>
</head>
<body>
<div class="clock">
<div class="hand hr"></div>
<div class="hand min"></div>
<div class="hand sec"></div>
<div class="num num1">1</div>
<div class="num num2">2</div>
<div class="num num3">3</div>
<div class="num num4">4</div>
<div class="num num5">5</div>
<div class="num num6">6</div>
<div class="num num7">7</div>
<div class="num num8">8</div>
<div class="num num9">9</div>
<div class="num num10">10</div>
<div class="num num11">11</div>
<div class="num num12">12</div>
</div>
<select id="timezone">
<option value="UTC">UTC</option>
<option value="IST">IST (Indian Standard Time)</option>
<option value="PST">PST (Pacific Standard Time)</option>
<option value="CET">CET (Central European Time)</option>
<option value="EST">EST (Eastern Standard Time)</option>
<option value="JST">JST (Japan Standard Time)</option>
<option value="AEST">AEST (Australian Eastern Standard Time)</option>
<!-- Add more time zones as needed -->
</select>
<script>
const hourHand = document.querySelector('.hand.hr');
const minuteHand = document.querySelector('.hand.min');
const secondHand = document.querySelector('.hand.sec');
function setClock() {
const now = new Date();
const selectedTimeZone = document.getElementById('timezone').value;
let offsetHours = 0;
let offsetMinutes = 0;
switch (selectedTimeZone) {
case 'IST':
offsetHours = 5;
offsetMinutes = 30;
break;
case 'PST':
offsetHours = -8;
break;
case 'CET':
offsetHours = 1;
break;
case 'EST':
offsetHours = -5;
break;
case 'JST':
offsetHours = 9;
break;
case 'AEST':
offsetHours = 10;
break;
// Add more time zone offsets as needed
}
const utcHours = now.getUTCHours();
const utcMinutes = now.getUTCMinutes();
const utcSeconds = now.getUTCSeconds();
let hours = utcHours + offsetHours;
let minutes = utcMinutes + offsetMinutes;
let seconds = utcSeconds;
if (minutes >= 60) {
hours += Math.floor(minutes / 60);
minutes = minutes % 60;
} else if (minutes < 0) {
hours -= Math.ceil(Math.abs(minutes) / 60);
minutes = (60 + (minutes % 60)) % 60;
}
hours = (hours + 24) % 24;
// Update the analog clock hands
const secondsRatio = seconds / 60;
const minutesRatio = (minutes + seconds / 60) / 60;
const hoursRatio = (hours % 12 + minutes / 60) / 12;
setRotation(secondHand, secondsRatio);
setRotation(minuteHand, minutesRatio);
setRotation(hourHand, hoursRatio);
}
function setRotation(element, rotationRatio) {
element.style.setProperty('--rotation', rotationRatio * 360);
}
document.getElementById('timezone').addEventListener('change', setClock);
setClock(); // Set the initial position of the clock hands
setInterval(setClock, 1000); // Update the clock every second
</script>
</body>
</html>
8)Full JavaScript
//variables
// var
// let
// const a = 4;
// console.log(a);
// a = 5;
// var x = 30;
// if(x>5){
// let y = 20;
// console.log(y);
// }
// var x = "hello world";
// var firstName = "greatstack"
// let
//scope in js
// var x = "hello, Manraj";
// function example(){
// console.log(x);
// }
// example();
// console.log(x);
// function example(){
// var x = "hello, Manraj";
// console.log(x);
// }
// Block scope
// function example(){
// if(true){
// let x = "hello, Manraj";
// console.log(x);
// }
// }
// example();
// console.log(x);
// Data types in js
// string
// let firstName = "Manraj";
// let lastName = "Chandwani";
// let num = 100;
// console.log(num);
//Boolean
// let isTrue = true;
// let isFalse = false;
// console.log(isTrue);
// console.log(isFalse);
// null
// let x = null;
// console.log(x);
// console.log(null == undefined);
// undefined
// let x;
// console.log(x);
// object
// let person = {
// firstName: "Manraj",
// lastName: "Chandwani",
// age: 25,
// isMarried: true
// }
// console.log(person);
// console.log(person.firstName);
// console.log(person["lastName"]);
// console.log(person.age);
// let x = 20<10;
// console.log(typeof x);
// let age;
// console.log(age);
// console.log(typeof age);
//Data type conversion
// function msg(){
// let x = "10";
// let y = 20;
// let z = x + y;
// console.log(z);
// console.log(typeof z);
// console.log(x+y);
// console.log(typeof x+y);
// console.log(Number(x)+y);
// console.log(typeof Number(x)+y);
// }
//fuction in js
// function Manraj(firstName , lastName){
// console.log(firstName + " " + lastName);
// }
// Manraj("Manraj" , "Chandwani");
// youraj("YT");
//Default parameters
// function sum(x,y){
// console.log(x+y); //you can add */%-+ in x()y
// }
// sum(10,20);
//Callbacks in js
// function display(result){
// console.log(result);
// }
// function add(x,y,callback){
// let z = x+y;
// callback(z); //callback function
// }
// add(10,20,display);
9)Clock .C++
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
int h, m, s, a, err;
err = a = 0;
while (err == 0)
{
cout << "Enter hour:" << endl;
cin >> h;
cout << "Enter minute:" << endl;
cin >> m;
cout << "Enter seconds:" << endl;
cin >> s;
if (h < 24 && m < 60 && s < 60)
err++;
else
{
system("cls");
cout << "Invalid time input. Please enter again." << endl;
}
}
while (a == 0)
{
system("cls");
cout << h << ":" << m << ":" << s << endl;
Sleep(1000);
s++;
if (s == 60)
{
s = 0;
m++;
}
if (m == 60)
{
m = 0;
h++;
}
if (h == 24)
{
h = 0;
}
}
return 0;
}
10)Your account .C++
#include <iostream>
using namespace std;
class bank
{
char name[100], address[100], y;
int balance;
public:
void open_account();
void deposite_money();
void withdraw_money();
void display_account();
};
void bank::open_account()
{
cout << "Enter your full name: ";
cin.ignore();
cin.getline(name, 100);
cout << "Enter your address: ";
cin.getline(address, 100);
cout << "What type of account do you want to open? Savings (s) or Current (c): ";
cin >> y;
cout << "Enter amount for deposit: ";
cin >> balance;
cout << "Your account has been created successfully\n";
}
void bank::deposite_money()
{
int a;
cout << "Enter amount for deposit: ";
cin >> a;
balance += a;
cout << "Total amount after deposit: " << balance << endl;
}
void bank::withdraw_money()
{
int b;
cout << "Enter amount to withdraw: ";
cin >> b;
if(b > balance) {
cout << "Insufficient balance!" << endl;
} else {
balance -= b;
cout << "Total amount after withdrawal: " << balance << endl;
}
}
void bank::display_account()
{
cout << "Your name: " << name << endl;
cout << "Your address: " << address << endl;
cout << "Your account type: " << (y == 's' ? "Savings" : "Current") << endl;
cout << "Your account balance: " << balance << endl;
}
int main()
{
int ch;
char x;
bank obj;
do
{
cout << "\n1) Open account \n";
cout << "2) Deposit money \n";
cout << "3) Withdraw money \n";
cout << "4) Display account \n";
cout << "5) Exit\n";
cout << "Select the option from above: ";
cin >> ch;
switch (ch)
{
case 1:
obj.open_account();
break;
case 2:
obj.deposite_money();
break;
case 3:
obj.withdraw_money();
break;
case 4:
obj.display_account();
break;
case 5:
exit(0);
default:
cout << "This option does not exist. Please try again.\n";
}
cout << "\nDo you want to select the next option? Press 'y' for Yes or 'n' for No: ";
cin >> x;
} while (x == 'y' || x == 'Y');
return 0;
}
11)Java patterns
package com.aimerz;
public class pattern2 {
public static void main(String[] args) {
for (int i = 0; i <= 5; i++) { // Loop for rows
for (int j = 0; j <= 9; j++) { // Loop for columns up to 9 for the extended pattern
// Conditions to print '*' for the first pattern (similar to K)
if (((j == 0 || j == 4) && i <= 2) || // Print '*' at the beginning or end of the first 3 rows
(i == 3 && (j == 1 || j == 3)) || // Print '*' at the 2nd and 4th position on the 4th row
(i == 4 && j == 2)) { // Print '*' in the middle of the 5th row
System.out.print("*");
}
// Conditions to print '*' for the letter 'I'
else if ((i == 0 || i == 4) && (j >= 5 && j <= 9) || j == 7) {
System.out.print("*");
}
// If no condition matches, print space
else {
System.out.print(" ");
}
}
System.out.println(); // Move to the next line after each row
}
}
}
package com.aimerz;
public class pattern2 {
public static void main(String[] args) {
String[] krishna = new String[]{
"K K RRRR III SSSS H H N N AAAAA",
"K K R R I S H H NN N A A",
"K K RRRR I SSSS HHHHH N N N AAAAA",
"K K R R I S H H N NN A A",
"K K R RR III SSSS H H N N A A"
};
for (String line : krishna) {
System.out.println(line);
}
}
}
package com.aimerz;
public class printingDiamond {
public static void main(String[] args) {
int n = 5;
int count = 1;
// Print the upper part of the diamond
for (int i = 1; i <= n; i++) {
// Print leading spaces
for (int j = i; j < n; j++) {
System.out.print(" ");
}
// Print numbers
for (int j = 1; j <= i; j++) {
System.out.print(count + " ");
count++;
}
System.out.println();
}
// Adjust count for the lower part of the diamond
count = count - n;
// Print the lower part of the diamond
for (int i = n - 1; i >= 1; i--) {
// Print leading spaces
for (int j = n; j > i; j--) {
System.out.print(" ");
}
// Print numbers
for (int j = 1; j <= i; j++) {
System.out.print(count + " ");
count++;
}
// Reset the count for the next line
count = count - 2 * i + 1;
System.out.println();
}
}
}
12)do while of colleges recommended
def evaluate_student(marks):
if marks >= 90:
return ("🎉 Fantastic job! With over 90%, you are highly likely to get into a top engineering college.",
["IIT Bombay", "IIT Delhi", "IIT Madras", "BITS Pilani"])
elif marks >= 75:
return ("👍 Great work! You have a strong chance of getting into a good engineering college.",
["NIT Trichy", "NIT Surathkal", "Delhi Technological University", "VIT Vellore"])
elif marks >= 50:
return ("🙂 Not bad! Consider applying to decent engineering colleges and keep improving.",
["SRM Institute of Science and Technology", "Manipal Institute of Technology", "Amity University", "Thapar University"])
elif marks >= 30:
return ("🤔 You might want to explore more options or improve your scores for better prospects.",
["Lovely Professional University", "Chandigarh University", "Graphic Era University", "KIIT Bhubaneswar"])
else:
return ("😕 Better luck next time! Focus on improving your grades for a brighter future.",
["Consider retaking exams or exploring alternative educational paths."])
# List to store student records
students = []
# Main loop for the system
while True:
print("\n--- College Recommendation System ---")
print("1. Add a new student")
print("2. View all students")
print("3. Total number of students")
print("4. Exit")
choice = input("Please choose an option (1-4): ").strip()
if choice == '1':
# Add a new student
name = input("Enter the student's name: ").strip()
try:
marks = float(input(f"Enter {name}'s junior college grade marks percentage: "))
feedback, colleges = evaluate_student(marks)
student_info = {"name": name, "marks": marks, "feedback": feedback, "colleges": colleges}
students.append(student_info)
print(f"\n{name}, {feedback}")
print("Recommended Colleges:")
for college in colleges:
print(f"- {college}")
except ValueError:
print("Please enter a valid number for the marks.")
continue
elif choice == '2':
# View all students
if students:
print("\n--- List of Students ---")
for idx, student in enumerate(students, start=1):
print(f"{idx}. {student['name']} - Marks: {student['marks']}%")
print(f" Feedback: {student['feedback']}")
print(" Recommended Colleges:")
for college in student['colleges']:
print(f" - {college}")
else:
print("No students have been added yet.")
elif choice == '3':
# Display total number of students
print(f"\nTotal number of students evaluated: {len(students)}")
elif choice == '4':
# Exit the system
print("Thank you for using the College Recommendation System!")
break
else:
print("Invalid option, please choose a valid option (1-4).")
13)Whack a Mole game
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Whack-a-Mole</title>
<style>
body {
font-family: 'Arial', sans-serif;
text-align: center;
background: url("https://example.com/your-new-background.jpg") no-repeat center center fixed;
background-size: cover;
margin: 0;
padding: 0;
}
h1 {
color: #fff;
margin-top: 20px;
font-size: 2.5em;
text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
}
h2 {
color: #fff;
font-size: 2em;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}
#board {
width: 600px;
height: 500px;
margin: 20px auto;
display: flex;
flex-wrap: wrap;
background-color: blue; /* Board color */
border: 3px solid #fff;
border-radius: 25px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
position: relative; /* Added for position reference */
}
#board div {
width: 200px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
#board div img {
width: 100px;
height: 100px;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
position: absolute;
}
.mole {
background-color: green; /* Mario color */
}
.plant {
background-color: red; /* Pot color */
}
.cactus {
background-color: black; /* Cactus color */
}
#restart {
display: none;
margin: 20px;
padding: 10px 20px;
font-size: 18px;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
#restart:hover {
background-color: #218838;
}
</style>
</head>
<body>
<h1>Whack-a-Mole</h1>
<h2 id="score">0</h2>
<div id="board"></div>
<button id="restart">Restart</button>
<script>
let currMoleTile;
let currPlantTile;
let currCactusTile;
let score = 0;
let gameOver = false;
window.onload = function () {
setGame();
}
function setGame() {
const board = document.getElementById("board");
board.innerHTML = ''; // Clear any existing tiles
for (let i = 0; i < 15; i++) { // Adjusted to fit 3x5 grid
let tile = document.createElement("div");
tile.id = i.toString();
tile.addEventListener("click", selectTile);
board.appendChild(tile);
}
setInterval(setMole, 1000); // Set mole every 1 second
setInterval(setPlant, 2000); // Set plant every 2 seconds
setInterval(setCactus, 3000); // Set cactus every 3 seconds
document.getElementById("restart").style.display = "none";
}
function getRandomTile() {
return Math.floor(Math.random() * 15).toString(); // Adjusted for 3x5 grid
}
function setMole() {
if (gameOver) return;
if (currMoleTile) {
currMoleTile.innerHTML = "";
}
let mole = document.createElement("img");
mole.src = "https://example.com/your-mole-image.png";
mole.className = 'mole'; // Added class
let num = getRandomTile();
if ((currPlantTile && currPlantTile.id === num) || (currCactusTile && currCactusTile.id === num)) {
setMole(); // Retry if the mole overlaps with a plant or cactus
return;
}
currMoleTile = document.getElementById(num);
currMoleTile.innerHTML = ""; // Clear tile content before appending
currMoleTile.appendChild(mole);
}
function setPlant() {
if (gameOver) return;
if (currPlantTile) {
currPlantTile.innerHTML = "";
}
let plant = document.createElement("img");
plant.src = "https://example.com/your-plant-image.png";
plant.className = 'plant'; // Added class
let num = getRandomTile();
if ((currMoleTile && currMoleTile.id === num) || (currCactusTile && currCactusTile.id === num)) {
setPlant(); // Retry if the plant overlaps with a mole or cactus
return;
}
currPlantTile = document.getElementById(num);
currPlantTile.innerHTML = ""; // Clear tile content before appending
currPlantTile.appendChild(plant);
}
function setCactus() {
if (gameOver) return;
if (currCactusTile) {
currCactusTile.innerHTML = "";
}
let cactus = document.createElement("img");
cactus.src = "https://example.com/your-cactus-image.png";
cactus.className = 'cactus'; // Added class
let num = getRandomTile();
if ((currMoleTile && currMoleTile.id === num) || (currPlantTile && currPlantTile.id === num)) {
setCactus(); // Retry if the cactus overlaps with a mole or plant
return;
}
currCactusTile = document.getElementById(num);
currCactusTile.innerHTML = ""; // Clear tile content before appending
currCactusTile.appendChild(cactus);
}
function selectTile() {
if (gameOver) return;
if (this === currMoleTile) {
score += 10;
document.getElementById("score").innerText = score.toString(); // Update score
} else if (this === currPlantTile) {
document.getElementById("score").innerText = "GAME OVER: " + score.toString(); // Update score
gameOver = true;
document.getElementById("restart").style.display = "inline-block"; // Show restart button
} else if (this === currCactusTile) {
document.getElementById("score").innerText = "GAME OVER: " + score.toString(); // Update score
gameOver = true;
document.getElementById("restart").style.display = "inline-block"; // Show restart button
}
}
document.getElementById("restart").addEventListener("click", function () {
score = 0;
gameOver = false;
document.getElementById("score").innerText = score.toString();
setGame(); // Reset the game
});
</script>
</body>
</html>
14)Currency converter App
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currency Converter</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(to right, #6a11cb, #2575fc);
color: #fff;
}
.container {
width: 90%;
max-width: 600px;
padding: 40px;
background: #fff;
border-radius: 12px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
text-align: center;
position: relative;
overflow: hidden;
}
.container::before {
content: "";
position: absolute;
top: -10%;
right: -10%;
width: 150%;
height: 150%;
background: rgba(0, 0, 0, 0.1);
border-radius: 50%;
z-index: 0;
}
h1 {
font-size: 2.5rem;
margin-bottom: 20px;
color: #333;
position: relative;
z-index: 1;
}
select, input {
padding: 15px;
margin: 10px 0;
width: calc(100% - 32px);
border: 2px solid #ddd;
border-radius: 8px;
box-sizing: border-box;
font-size: 1rem;
position: relative;
z-index: 1;
}
button {
padding: 15px;
background-color: #007bff;
border: none;
color: #fff;
border-radius: 8px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s, transform 0.2s;
position: relative;
z-index: 1;
}
button:hover {
background-color: #0056b3;
transform: scale(1.05);
}
button:active {
background-color: #004494;
}
.info {
margin-top: 20px;
padding: 20px;
background-color: #f8f9fa;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 1rem;
text-align: left;
color: #333;
position: relative;
z-index: 1;
}
.info h2 {
margin-top: 0;
color: #007bff;
}
.info p {
margin: 0;
}
@media (max-width: 768px) {
.container {
padding: 20px;
}
select, input, button {
width: calc(100% - 20px);
}
}
</style>
</head>
<body>
<div class="container">
<h1>Currency Converter</h1>
<form id="converter-form">
<input type="number" id="amount" placeholder="Amount" required>
<select id="from-currency">
<option value="USD">US Dollar (USD)</option>
<option value="EUR">Euro (EUR)</option>
<option value="GBP">British Pound (GBP)</option>
<option value="INR">Indian Rupee (INR)</option>
<!-- Add more currencies as needed -->
</select>
<select id="to-currency">
<option value="USD">US Dollar (USD)</option>
<option value="EUR">Euro (EUR)</option>
<option value="GBP">British Pound (GBP)</option>
<option value="INR">Indian Rupee (INR)</option>
<!-- Add more currencies as needed -->
</select>
<button type="button" onclick="convertCurrency()">Convert</button>
</form>
<div class="info" id="result"></div>
<div class="info" id="world-rupee-info">
<h2>About Indian Rupee (INR)</h2>
<p>The Indian Rupee (INR) is the official currency of India. It is abbreviated as INR and is symbolized by ₹. It is subdivided into 100 paise.</p>
</div>
</div>
<script>
async function convertCurrency() {
const amount = document.getElementById('amount').value;
const fromCurrency = document.getElementById('from-currency').value;
const toCurrency = document.getElementById('to-currency').value;
const resultDiv = document.getElementById('result');
if (!amount || fromCurrency === toCurrency) {
resultDiv.innerHTML = '<p style="color: red;">Please enter an amount and select different currencies.</p>';
return;
}
try {
const response = await fetch(`https://api.exchangerate-api.com/v4/latest/${fromCurrency}`);
const data = await response.json();
const rate = data.rates[toCurrency];
const convertedAmount = (amount * rate).toFixed(2);
resultDiv.innerHTML = `<p><strong>${amount} ${fromCurrency}</strong> is equal to <strong>${convertedAmount} ${toCurrency}</strong></p>`;
} catch (error) {
resultDiv.innerHTML = '<p style="color: red;">Error fetching conversion rate. Please try again later.</p>';
}
}
</script>
</body>
</html>
15)Jarvis 3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jarvis - Your Virtual Assistant</title>
<link rel="shortcut icon" href="Picsart_24-09-09_15-46-29-834.png" type="image/x-icon">
<style>
/* General Styling */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background: radial-gradient(circle at top, #1a1a2e, #000);
font-family: 'Arial', sans-serif;
color: white;
overflow: hidden;
}
/* Logo Styling */
#logo {
width: 200px;
height: auto;
animation: pulse 2s infinite;
transition: transform 0.3s ease;
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
/* Title Styling */
h1 {
font-size: 2.5rem;
margin-bottom: 20px;
text-shadow: 0 0 10px #ff105f, 0 0 20px #00f;
}
h1 span {
color: #ff105f;
font-weight: bold;
}
#name {
color: #ff105f;
}
#va {
color: #00ff6a;
}
/* Voice Animation */
#voice {
width: 150px;
display: none;
animation: glowing 1.5s infinite;
}
@keyframes glowing {
0% {
box-shadow: 0 0 5px #00ff6a;
}
50% {
box-shadow: 0 0 20px #00ff6a;
}
100% {
box-shadow: 0 0 5px #00ff6a;
}
}
/* Button Styling */
#btn {
background: linear-gradient(90deg, #ff105f, #00f);
padding: 15px 25px;
font-size: 1rem;
border: none;
border-radius: 50px;
color: #fff;
display: flex;
align-items: center;
gap: 10px;
box-shadow: 0 0 20px rgba(255, 17, 123, 0.8);
cursor: pointer;
transition: all 0.3s ease;
}
#btn img {
width: 25px;
height: 25px;
}
#btn:hover {
transform: scale(1.05);
box-shadow: 0 0 30px rgba(255, 17, 123, 1);
}
/* Responsive Styling */
@media screen and (max-width: 600px) {
h1 {
font-size: 1.8rem;
}
#btn {
padding: 10px 20px;
font-size: 0.9rem;
}
}
</style>
</head>
<body>
<img src="Picsart_24-09-09_15-46-29-834.png" alt="Jarvis Logo" id="logo">
<h1>I am <span id="name">Jarvis</span>, your <span id="va">Virtual Assistant</span></h1>
<img src="voice.gif" alt="Voice Animation" id="voice">
<button id="btn">
<img src="karaoke.png" alt="Microphone Icon">
<span id="content">Click to Talk to Me</span>
</button>
<script>
let btn = document.querySelector("#btn");
let content = document.querySelector("#content");
let voice = document.querySelector("#voice");
let synth = window.speechSynthesis;
let femaleVoice = null;
function getFemaleVoice() {
let voices = synth.getVoices();
femaleVoice = voices.find(voice => voice.name.includes('Female')) || voices[0];
}
function speak(text) {
console.log("Speaking:", text); // Debugging
let textSpeak = new SpeechSynthesisUtterance(text);
textSpeak.voice = femaleVoice;
textSpeak.rate = 1;
textSpeak.pitch = 1;
textSpeak.volume = 1;
textSpeak.lang = "en-GB";
synth.speak(textSpeak);
}
function wishMe() {
let hour = new Date().getHours();
if (hour < 12) {
speak("Good Morning, sir!");
} else if (hour < 16) {
speak("Good Afternoon, sir!");
} else {
speak("Good Evening, sir!");
}
}
window.addEventListener("load", () => {
wishMe();
getFemaleVoice(); // Load female voice on load
});
let speechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
let recognition = new speechRecognition();
recognition.continuous = true; // Keep listening
recognition.onresult = (event) => {
let transcript = event.results[event.resultIndex][0].transcript.toLowerCase().trim();
console.log("Heard:", transcript); // Debugging
content.innerText = transcript;
takeCommand(transcript);
};
btn.addEventListener("click", () => {
recognition.start();
console.log("Listening started"); // Debugging
btn.style.display = "none";
voice.style.display = "block";
speak("I am listening...");
});
function takeCommand(message) {
console.log("Command received:", message); // Debugging
if (message.includes("hello") || message.includes("hey")) {
speak("Hello sir, how may I assist you?");
} else if (message.includes("who are you")) {
speak("I am Jarvis, your virtual assistant, created by Krishna Patil Rajput Sir.");
} else if (message.includes("open")) {
let app = message.split("open")[1].trim();
speak(`Opening ${app}...`);
if (app.includes("youtube")) {
window.open("https://www.youtube.com/", "_blank");
} else if (app.includes("google")) {
window.open("https://www.google.com/", "_blank");
} else {
speak(`I couldn't find an application named ${app}. Searching the web instead.`);
window.open(`https://www.google.com/search?q=${app}`, "_blank");
}
} else if (message.includes("time")) {
let time = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
speak(`The current time is ${time}`);
} else if (message.includes("date")) {
let date = new Date().toLocaleDateString([], { day: 'numeric', month: 'long', year: 'numeric' });
speak(`Today's date is ${date}`);
} else {
speak(`Searching the web for ${message}`);
window.open(`https://www.google.com/search?q=${message}`, "_blank");
}
}
recognition.onend = () => {
console.log("Recognition ended"); // Debugging
voice.style.display = "none";
btn.style.display = "flex";
speak("sorry sir could not recognize that. please repeat that");
};
// Ensure voices are loaded
synth.onvoiceschanged = getFemaleVoice;
</script>
</body>
</html>
16)Stone paper scissor
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Stone Paper Scissors</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
body {
width: 100vw;
height: 100vh;
background: linear-gradient(45deg, #1e3c72, #2a5298, #1e3c72);
background-size: 400% 400%;
animation: gradient 10s ease infinite;
display: flex;
align-items: center;
justify-content: center;
color: white;
}
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.game {
width: 80vw;
height: 80vh;
max-width: 450px;
background: rgba(26, 31, 36, 0.9);
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 15px;
border-radius: 15px;
text-align: center;
box-shadow: 0px 0px 20px rgba(255, 255, 255, 0.1);
}
.hand {
width: 100%;
height: 40%;
display: flex;
align-items: center;
justify-content: space-around;
font-size: 80px;
}
.choices {
width: 100%;
height: 20%;
display: flex;
align-items: center;
justify-content: space-around;
}
.choice {
width: 70px;
height: 70px;
border-radius: 50%;
background: #3b3b3b;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.8), -2px -2px 10px rgba(0, 0, 0, 0.8);
font-size: 20px;
transition: all 0.3s;
cursor: pointer;
}
.choice:hover {
box-shadow: inset 2px 2px 10px rgba(59, 135, 197, 0.8), -2px -2px 10px rgba(187, 71, 205, 0.8);
transform: scale(1.1);
}
.result {
font-size: 20px;
margin-top: 10px;
}
.scoreboard {
display: flex;
justify-content: space-between;
padding: 10px;
border-top: 1px solid #555;
border-bottom: 1px solid #555;
}
.score {
font-size: 18px;
}
.reset-btn {
margin-top: 10px;
padding: 10px;
background: #555;
border: none;
color: white;
cursor: pointer;
border-radius: 5px;
transition: all 0.3s;
}
.reset-btn:hover {
background: #333;
}
</style>
</head>
<body>
<div class="game">
<div class="scoreboard">
<div class="score">Player Score: <span id="player-score">0</span></div>
<div class="score">Computer Score: <span id="computer-score">0</span></div>
<div class="score">Winning Streak: <span id="winning-streak">0</span></div>
</div>
<div class="hand">
<div class="you-div" id="user-choice">👊</div>
<div class="computer-div" id="computer-choice">👊</div>
</div>
<div class="choices">
<div class="choice" id="stone">👊</div>
<div class="choice" id="paper">✋</div>
<div class="choice" id="scissor">✌</div>
</div>
<div class="result" id="result">Make your move!</div>
<button class="reset-btn" id="reset">Reset Game</button>
</div>
<script>
// Available choices for the game
const choices = ['stone', 'paper', 'scissor'];
let playerScore = 0;
let computerScore = 0;
let winningStreak = 0;
const userChoiceDiv = document.getElementById('user-choice');
const computerChoiceDiv = document.getElementById('computer-choice');
const resultDiv = document.getElementById('result');
const playerScoreSpan = document.getElementById('player-score');
const computerScoreSpan = document.getElementById('computer-score');
const winningStreakSpan = document.getElementById('winning-streak');
const resetButton = document.getElementById('reset');
// Add event listeners to choices
document.querySelectorAll('.choice').forEach(choice => {
choice.addEventListener('click', () => {
const userChoice = choice.id;
const computerChoice = choices[Math.floor(Math.random() * 3)];
updateChoices(userChoice, computerChoice);
determineResult(userChoice, computerChoice);
});
});
// Update the display of user and computer choices
function updateChoices(userChoice, computerChoice) {
userChoiceDiv.textContent = convertToEmoji(userChoice);
computerChoiceDiv.textContent = convertToEmoji(computerChoice);
}
// Convert choice to its respective emoji
function convertToEmoji(choice) {
if (choice === 'stone') return '👊';
if (choice === 'paper') return '✋';
if (choice === 'scissor') return '✌';
}
// Determine the result of the game and update scores
function determineResult(user, computer) {
if (user === computer) {
resultDiv.textContent = 'It\'s a tie!';
winningStreak = 0;
} else if (
(user === 'stone' && computer === 'scissor') ||
(user === 'paper' && computer === 'stone') ||
(user === 'scissor' && computer === 'paper')
) {
resultDiv.textContent = 'You win!';
playerScore++;
winningStreak++;
} else {
resultDiv.textContent = 'You lose!';
computerScore++;
winningStreak = 0;
}
updateScoreboard();
}
// Update the scoreboard display
function updateScoreboard() {
playerScoreSpan.textContent = playerScore;
computerScoreSpan.textContent = computerScore;
winningStreakSpan.textContent = winningStreak;
}
// Reset the game
resetButton.addEventListener('click', () => {
playerScore = 0;
computerScore = 0;
winningStreak = 0;
updateScoreboard();
resultDiv.textContent = 'Make your move!';
userChoiceDiv.textContent = '👊';
computerChoiceDiv.textContent = '👊';
});
</script>
</body>
</html>
17)Music player
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Music Player</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(to right, #6a11cb, #2575fc);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
color: white;
}
.music-player {
background-color: rgba(255, 255, 255, 0.9);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
text-align: center;
width: 350px;
}
h1 {
font-size: 26px;
margin-bottom: 20px;
color: #333;
}
audio {
width: 100%;
margin-bottom: 20px;
border-radius: 10px;
background-color: #eaeaea;
border: 1px solid #ccc;
}
.controls {
margin-top: 15px;
display: flex;
flex-direction: column;
gap: 10px;
}
.button-box {
margin: 10px 0;
}
button {
padding: 12px;
font-size: 18px;
border: none;
border-radius: 8px;
cursor: pointer;
background-color: #28a745;
color: white;
transition: background-color 0.3s, transform 0.2s;
width: 100%;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
position: relative;
overflow: hidden;
}
button:hover {
background-color: #218838;
transform: scale(1.05);
}
button:active {
transform: scale(0.95);
}
button:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 8px;
opacity: 0;
transition: opacity 0.3s;
z-index: 0;
}
button:hover:before {
opacity: 1;
}
.footer {
margin-top: 20px;
font-size: 14px;
color: #777;
}
</style>
</head>
<body>
<div class="music-player">
<h1>Music Player</h1>
<audio id="audio" controls>
<source id="audio-source" src="" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
<div class="controls">
<div class="button-box">
<button onclick="playSong('https://drive.google.com/uc?export=download&id=YOUR_TECHNO_GAMERZ_LIFE_FILE_ID')">Techno Gamerz Life</button>
</div>
<div class="button-box">
<button onclick="playSong('https://drive.google.com/uc?export=download&id=YOUR_CARRYMINATI_YALGAAR_FILE_ID')">CarryMinati Yalgaar</button>
</div>
<div class="button-box">
<button onclick="playSong('https://drive.google.com/uc?export=download&id=YOUR_GAMERS_SONG_FILE_ID')">Gamers Song</button>
</div>
<!-- Add more buttons here -->
</div>
<div class="footer">© 2024 Your Name</div>
</div>
<script>
function playSong(song) {
const audio = document.getElementById('audio');
const audioSource = document.getElementById('audio-source');
audioSource.src = song;
audio.load();
audio.play();
}
</script>
</body>
</html>
18)Optics game
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Optics Simulation Game</title>
<style>
body { text-align: center; background-color: #f9f9f9; }
canvas { border: 2px solid #444; background-color: #fff; margin-top: 20px; }
.controls { margin-top: 10px; }
.controls input, .controls select { margin: 5px; }
</style>
</head>
<body>
<h1>Advanced Optics Simulation</h1>
<canvas id="opticsCanvas" width="800" height="600"></canvas>
<div class="controls">
<label for="angle">Angle of Incidence:</label>
<input type="range" id="angle" min="0" max="90" value="45">
<label for="mirrorType">Mirror Type:</label>
<select id="mirrorType">
<option value="plane">Plane Mirror</option>
<option value="concave">Concave Mirror</option>
<option value="convex">Convex Mirror</option>
</select>
<label for="laserColor">Laser Color:</label>
<select id="laserColor">
<option value="red">Red</option>
<option value="white">White</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
</div>
<script>
const canvas = document.getElementById('opticsCanvas');
const ctx = canvas.getContext('2d');
const angleInput = document.getElementById('angle');
const mirrorTypeSelect = document.getElementById('mirrorType');
const laserColorSelect = document.getElementById('laserColor');
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
let angleOfIncidence = 45;
let mirrorType = 'plane';
let laserColor = 'red';
// Draw the optics interface (mirror)
function drawInterface() {
ctx.beginPath();
ctx.moveTo(0, centerY);
ctx.lineTo(canvas.width, centerY);
ctx.strokeStyle = 'black';
ctx.lineWidth = 3;
ctx.stroke();
if (mirrorType === 'concave' || mirrorType === 'convex') {
ctx.beginPath();
const radius = 200;
const startAngle = Math.PI;
const endAngle = 2 * Math.PI;
ctx.arc(centerX, centerY + (mirrorType === 'concave' ? -radius : radius), radius, startAngle, endAngle, mirrorType === 'convex');
ctx.strokeStyle = 'gray';
ctx.lineWidth = 2;
ctx.stroke();
}
}
// Calculate reflection for different mirror types
function calculateReflection(incidentAngle) {
if (mirrorType === 'plane') {
return incidentAngle;
}
else if (mirrorType === 'concave') {
return -incidentAngle; // For simplicity, flip the angle
}
else if (mirrorType === 'convex') {
return -incidentAngle; // Flip as well, but further corrections can be applied
}
return incidentAngle;
}
// Draw the incident, reflected, and additional rays
function drawRays() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawInterface();
// Incident ray
const incidentX = centerX - Math.cos((angleOfIncidence * Math.PI) / 180) * 200;
const incidentY = centerY - Math.sin((angleOfIncidence * Math.PI) / 180) * 200;
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(incidentX, incidentY);
ctx.strokeStyle = laserColor;
ctx.lineWidth = 2;
ctx.stroke();
ctx.fillStyle = laserColor;
ctx.fillText('Incident Ray', incidentX + 10, incidentY + 10);
// Reflected ray
const reflectedAngle = calculateReflection(angleOfIncidence);
const reflectedX = centerX + Math.cos((reflectedAngle * Math.PI) / 180) * 200;
const reflectedY = centerY - Math.sin((reflectedAngle * Math.PI) / 180) * 200;
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(reflectedX, reflectedY);
ctx.strokeStyle = 'blue';
ctx.lineWidth = 2;
ctx.stroke();
ctx.fillStyle = 'blue';
ctx.fillText('Reflected Ray', reflectedX - 80, reflectedY - 10);
// Additional rays for a laser effect
for (let i = -30; i <= 30; i += 10) {
const multipleIncidentX = centerX - Math.cos(((angleOfIncidence + i) * Math.PI) / 180) * 200;
const multipleIncidentY = centerY - Math.sin(((angleOfIncidence + i) * Math.PI) / 180) * 200;
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(multipleIncidentX, multipleIncidentY);
ctx.strokeStyle = `rgba(255,0,0,${0.3 - i / 100})`; // Varying laser intensity
ctx.lineWidth = 1;
ctx.stroke();
const multipleReflectedAngle = calculateReflection(angleOfIncidence + i);
const multipleReflectedX = centerX + Math.cos((multipleReflectedAngle * Math.PI) / 180) * 200;
const multipleReflectedY = centerY - Math.sin((multipleReflectedAngle * Math.PI) / 180) * 200;
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(multipleReflectedX, multipleReflectedY);
ctx.strokeStyle = `rgba(0,0,255,${0.3 - i / 100})`; // Blue reflection rays
ctx.lineWidth = 1;
ctx.stroke();
}
}
// Update the angle of incidence based on the slider input
angleInput.addEventListener('input', () => {
angleOfIncidence = parseInt(angleInput.value, 10);
drawRays();
});
// Update the mirror type based on the select input
mirrorTypeSelect.addEventListener('change', () => {
mirrorType = mirrorTypeSelect.value;
drawRays();
});
// Update the laser color based on the select input
laserColorSelect.addEventListener('change', () => {
laserColor = laserColorSelect.value;
drawRays();
});
drawRays(); // Initial drawing
</script>
</body>
</html>
19) Gsap Tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gsap</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
background-color: black;
width: 100%;
height: 100%;
}
.box {
width: 200px;
background-color: rgb(77, 149, 211);
height: 200px;
}
.box1 {
width: 200px;
background-color: rgb(77, 211, 97);
height: 200px;
}
.box2 {
width: 200px;
background-color: yellow;
height: 200px;
}
nav {
width: 100%;
height: 100px;
padding: 20px;
display: flex;
background-color: rgb(211, 77, 77);
box-sizing: border-box;
justify-content: space-between;
align-items: center;
}
nav ul {
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
list-style-type: none;
}
#page1 {
.box1 {
width: 200px;
height: 200px;
background-color: brown;
}
.box2 {
width: 200px;
height: 200px;
background-color: rgb(77, 149, 211);
}
.box3 {
width: 200px;
height: 200px;
background-color: rgb(77, 211, 97);
}
}
</style>
</head>
<body>
<div class="box">
</div>
<div class="box1">
</div>
<div class="box2"></div>
</div>
<nav>
<h1>
LOGO
</h1>
<ul>
<li>Home</li>
<li>Menu</li>
<li>Contact US</li>
<li>About Gsap</li>
</ul>
</nav>
<div id="page1">
<div class="box1">
</div>
<div id="page2">
<div class="box2">
</div>
</div>
<div id="page3">
<div class="box3">
</div>
<script src=" https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"
integrity="sha512-7eHRwcbYkK4d9g/6tD/mhkf++eoTHwpNM9woBxtPUBWm67zeAfFC+HrdoE2GanKeocly/VxeLvIqwvCdk7qScg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"
integrity="sha512-onMTRKJBKz8M1TnqqDuGBlowlH0ohFzMXYRNebz+yOcc5TQr/zAKsthzhuv0hiyUKEiQEQXEynnXCvNTOk50dg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
gsap.to(".box", {
x: 500,
y: 300,
duration: 3,
delay: 5,
backgroundColor: "red",
rotate: 20,
repeat: 1,
yoyo: 2,
})
gsap.from(".box1", {
x: 500,
y: 300,
duration: 3,
delay: 2,
backgroundColor: "red",
rotate: 20,
repeat: 1, //-1 for infinite repeats
yoyo: 2, // it comes to same place
})
//Gsap Timeline
let tl = gsap.timeline()
tl.to(".box2", {
x: 500,
y: 300,
duration: 5,
delay: 2,
backgroundColor: "red",
rotate: 20,
repeat: 1, //-1 for infinite repeats
yoyo: 2, // it comes to same place
})
gsap.from("nav ul li", {
y: -100,
duration: 2,
stagger: 1, //one by one -1 to from last one to first
})
//scroll trigger
gsap.from(".box1", {
x: 800,
duration: 1
})
gsap.from(".box2", {
x: 800,
duration: 1,
scrollTrigger: {
trigger: ".box2",
start: "top center"
}
})
gsap.from(".box3", {
x: 800,
duration: 1
})
</script>
</body>
</html>
20)Bubble Animations using Gsap
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Attractive Bubble Transformation</title>
<style>
/* Reset default browser styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Styling body */
body {
background-color: #000;
color: #ffffff;
font-family: Arial, sans-serif;
overflow-x: hidden;
}
/* Bubble container styling */
.bubble-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
.bubble {
position: absolute;
border-radius: 50%;
pointer-events: none;
background: radial-gradient(circle, rgba(255, 255, 255, 0.6), rgba(255, 215, 0, 0.4));
box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.8);
}
/* Styling the navigation bar */
nav {
width: 100%;
height: 80px;
padding: 15px 20px;
background-color: rgb(51, 51, 153);
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
position: sticky;
top: 0;
z-index: 1000;
}
/* Styling logo and menu */
nav h1 {
color: #fff;
font-size: 24px;
animation: floatTitle 3s ease-in-out infinite;
}
nav ul {
display: flex;
gap: 20px;
list-style-type: none;
}
nav ul li {
color: #fff;
cursor: pointer;
padding: 5px 10px;
transition: background-color 0.3s ease;
}
nav ul li:hover {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 5px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
@keyframes floatTitle {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
</style>
</head>
<body>
<!-- Navigation Bar -->
<nav>
<h1>BUBBLE DANCE</h1>
<ul>
<li><a href="https://example.com/home">Home</a></li>
<li><a href="https://example.com/menu">Menu</a></li>
<li><a href="https://example.com/contact">Contact Us</a></li>
<li><a href="https://example.com/about">About Me</a></li>
</ul>
</nav>
<!-- Main bubble container -->
<div class="bubble-container" id="bubbleContainer"></div>
<!-- Importing GSAP libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"
integrity="sha512-7eHRwcbYkK4d9g/6tD/mhkf++eoTHwpNM9woBxtPUBWm67zeAfFC+HrdoE2GanKeocly/VxeLvIqwvCdk7qScg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"
integrity="sha512-onMTRKJBKz8M1TnqqDuGBlowlH0ohFzMXYRNebz+yOcc5TQr/zAKsthzhuv0hiyUKEiQEQXEynnXCvNTOk50dg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
// Create bubbles with different sizes
const bubbleContainer = document.getElementById("bubbleContainer");
for (let i = 0; i < 40; i++) {
const bubble = document.createElement("div");
const size = Math.random() * 80 + 20; // Random sizes between 20 and 100px
bubble.style.width = `${size}px`;
bubble.style.height = `${size}px`;
bubble.style.top = `${Math.random() * 100}%`;
bubble.style.left = `${Math.random() * 100}%`;
bubble.style.background = `radial-gradient(circle, rgba(255,255,255,0.6), rgba(${Math.random() * 255},${Math.random() * 255},${Math.random() * 255},0.4))`;
bubble.classList.add("bubble");
bubbleContainer.appendChild(bubble);
}
// Animate bubbles with pulsing, color changes, and floating effects
gsap.to(".bubble", {
duration: 6,
x: "random(-100, 100)",
y: "random(-100, 100)",
scale: "random(0.5, 1.5)",
backgroundColor: "random([#fbc02d, #29b6f6, #ef5350, #66bb6a, #ab47bc])",
borderRadius: "random(30%, 70%)",
boxShadow: "0px 0px 30px rgba(255, 255, 255, 1)",
repeat: -1,
yoyo: true,
ease: "sine.inOut",
stagger: {
amount: 1.5,
from: "random"
}
});
// Adding a slight rotation effect for each bubble
gsap.to(".bubble", {
rotation: "random(-180, 180)",
duration: 8,
repeat: -1,
yoyo: true,
ease: "power2.inOut"
});
// Animate navigation items on page load
gsap.from("nav ul li", {
y: -100,
duration: 1,
opacity: 0,
stagger: 0.2,
ease: "bounce",
onComplete: function () {
gsap.to("nav ul li", {
scale: 1.1,
yoyo: true,
repeat: -1,
duration: 1.5,
ease: "power1.inOut"
});
}
});
</script>
</body>
</html>
21)AI chatbot with API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My AI Chatbot Assistant</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
body {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(45deg, #0e1538, #00ccff);
padding-top: 20px;
overflow: hidden;
flex-direction: column;
}
.container {
width: 80%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-bottom: auto;
}
.container h1,
.container h2 {
text-align: center;
background: linear-gradient(90deg, #ff0099, #ff9900, #00ccff, #ff0099);
background-size: 400%;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: textGradient 6s ease-in-out infinite;
}
.container h1 {
font-size: 4vw;
margin-bottom: 10px;
}
.container h2 {
font-size: 2.5vw;
margin-bottom: 20px;
color: #fff;
}
@keyframes textGradient {
0% {
background-position: 0%;
}
50% {
background-position: 100%;
}
100% {
background-position: 0%;
}
}
.chat-container {
width: 80%;
max-height: 60vh;
overflow-y: auto;
background: linear-gradient(120deg, #f0f0f0, #d1d1d1);
padding: 15px;
border-radius: 15px;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
margin-bottom: 10px;
position: relative;
}
.user-chat-box,
.ai-chat-box {
display: flex;
align-items: flex-start;
margin-bottom: 10px;
}
.user-chat-box img,
.ai-chat-box img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.user-chat-box p,
.ai-chat-box p {
padding: 10px 15px;
border-radius: 15px;
max-width: 70%;
font-size: 1rem;
word-wrap: break-word;
}
.user-chat-box {
justify-content: flex-end;
}
.user-chat-box p {
background-color: #007bff;
color: #fff;
margin-left: auto;
}
.ai-chat-box p {
background-color: #d4edda;
color: #155724;
}
.prompt-area {
width: 100%;
height: 100px;
background-color: #003366;
position: fixed;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0px -4px 10px rgba(0, 0, 0, 0.3);
}
#prompt {
width: 60%;
height: 50px;
padding: 10px 15px;
border-radius: 25px;
border: 2px solid #00ccff;
outline: none;
font-size: 1.2rem;
transition: 0.3s;
}
#prompt:focus {
border: 2px solid #ff9900;
box-shadow: 0px 0px 10px rgba(255, 153, 0, 0.7);
}
#btn {
width: 60px;
height: 60px;
margin-left: 15px;
background-color: #ff0099;
border: none;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: 0.3s;
}
#btn:hover {
background-color: #ff9900;
transform: scale(1.1);
box-shadow: 0px 0px 10px rgba(255, 153, 0, 0.7);
}
#btn img {
width: 24px;
height: 24px;
filter: invert(1);
}
.loading {
display: none;
}
</style>
</head>
<body>
<div class="container">
<h1>Your Own AI Chatbot Assistant</h1>
<h2>Talk to your Own AI Chatbot</h2>
<div class="chat-container" id="chatContainer">
<div class="user-chat-box">
<img src="scene-Iron-Man.webp" alt="User">
<p>Hello, how can I assist you today?</p>
</div>
<div class="ai-chat-box">
<img src="AI-robo-lab.jpg" alt="AI">
<p>I am here to help you! Feel free to ask anything.</p>
<img class="loading" src="giphy.webp" alt="loading" height="50px">
</div>
</div>
</div>
<div class="prompt-area">
<input type="text" id="prompt" placeholder="Ask something to your AI...">
<button id="btn"><img src="sent-stroke-rounded.svg" alt="Send"></button>
</div>
<script>
const promptInput = document.querySelector("#prompt");
const sendButton = document.querySelector("#btn");
const chatContainer = document.querySelector("#chatContainer");
const loadingAnimation = document.querySelector(".loading");
// Define your API URL and API key securely
const Api_Url = ''; // Replace with the correct Gemini AI endpoint
const apiKey = 'YOUR_API_KEY'; // Ensure this is kept secret and not exposed in production
sendButton.addEventListener("click", async function () {
const userMessage = promptInput.value.trim();
if (userMessage) {
// Create a user message element
createChatBox('user', userMessage);
// Clear the input field
promptInput.value = "";
// Show loading animation
loadingAnimation.style.display = "block";
// Fetch AI response
try {
const response = await fetch(Api_Url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}` // Use Bearer token for authorization
},
body: JSON.stringify({
prompt: userMessage,
max_tokens: 150
})
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
loadingAnimation.style.display = "none"; // Hide loading animation
// Create AI message element
createChatBox('ai', data.choices[0].text.trim());
} catch (error) {
console.error("Error fetching AI response:", error);
loadingAnimation.style.display = "none"; // Hide loading animation on error
}
}
});
// Function to create and append chat boxes
function createChatBox(type, message) {
const chatBox = document.createElement("div");
chatBox.classList.add(type === 'user' ? "user-chat-box" : "ai-chat-box");
const chatImage = document.createElement("img");
chatImage.src = type === 'user' ? "scene-Iron-Man.webp" : "AI-robo-lab.jpg"; // Set image based on chat type
chatBox.appendChild(chatImage);
const chatText = document.createElement("p");
chatText.textContent = message;
chatBox.appendChild(chatText);
// Append message to chat container
chatContainer.appendChild(chatBox);
chatContainer.scrollTop = chatContainer.scrollHeight; // Scroll to bottom
}
</script>
</body>
</html>
22) Html Basics
<!-- History of HTML
1980 to 1990: Tim Berners-Lee created the World Wide Web, but it wasn't taken seriously at first.
In 1991, the first website was created by Tim Berners-Lee. Website URL: http://info.cern.ch/hypertext/WWW/TheProject.html
document.designMode = "on"; // This is used to edit the HTML code
document.designMode = "off"; // This is used to stop editing the HTML code
-->
<!-- Chapter 1 -->
<!-- SEO - Search Engine Optimization -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Trial Web Page</title>
<style>
/* Center the content inside the flex container */
.center {
display: flex;
justify-content: center;
align-items: center;
margin: 20px 0;
}
body {
font-family: Arial, sans-serif;
padding: 20px;
line-height: 1.5;
}
</style>
</head>
<body>
<h1>This is my first web page</h1>
<a href="https://www.google.com" target="_blank">Google</a>
<h1>This is my short big line</h1>
<h2>This is my short big line</h2>
<h3>This is my short big line</h3>
<h4>This is my short big line</h4>
<!-- Corrected Google logo -->
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google logo"
height="120" width="250">
<br>
<b>This is bold</b><br>
<i>This is italic</i><br>
<u>This is underline</u><br>
<p>This is a paragraph</p>
<!-- Corrected Twitter logo -->
<img src="https://abs.twimg.com/icons/apple-touch-icon-192x192.png" alt="Twitter logo" height="120" width="250">
<big>Hey, this is my webpage</big><br>
<!-- Centering the small text -->
<div class="center">
<small>Hey, this is my webpage</small>
</div>
<hr>
<p>I am a line after hr</p>
this <sub> is </sub> subsript <br>
this <sup> is </sup> superscript.
H<sub>2</sub>O</sub> <br>
C<sub>6</sub>H<sub>12</sub>O<sub>6</sub><br>
CO<sub>2</sub>
<hr>
<p>
Hey
I
am good
</p>
<pre>hey
I this is for you
am good and you
<hr>
<h1>this is Html tutorial</h1>
<h2>Introduction</h2>
<p>Html is great and its nice language.</p>
<h3>History of Html</h3>
<hr>
<p>Tim Berners-Lee created the World Wide Web</p>
</pre>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSPg7vyAgDrLgoH6nfgT_BwD_Ycwbl_SbNYCQ&s" alt="dog">
<hr>
<H1>ABOUT ME</H1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum nemo optio natus autem aperiam asperiores id
cupiditate accusantium aspernatur nam. Dolorem eligendi pariatur laborum obcaecati recusandae culpa magnam
blanditiis velit. Officia, hic.</p>
<hr>
<span>hey</span><br>
<span>hey</span><br>
<H1>C + O<sub>2</sub> = Co<sub>2</sub></H1>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Krishna Patil Rajput</title>
<style>
/* General styling */
body {
font-family: Arial, sans-serif; /* Set the font style for the entire page */
margin: 0; /* Remove default margin */
padding: 0; /* Remove default padding */
background: #f0f0f0; /* Light gray background color */
}
header {
background: #333; /* Dark background for header */
color: #fff; /* White text color */
padding: 1em 0; /* Add padding to the top and bottom */
}
nav {
display: flex; /* Use flexbox layout */
justify-content: center; /* Center the content horizontally */
align-items: center; /* Center the content vertically */
}
nav a {
color: #fff; /* White text color for navigation links */
text-decoration: none; /* Remove underline from links */
margin: 0 15px; /* Add space between links */
padding: 5px 10px; /* Add padding inside the links */
transition: background 0.3s; /* Smooth transition for background change */
}
nav a:hover {
background: #575757; /* Darker background on hover */
border-radius: 5px; /* Rounded corners on hover */
}
hr {
border: none; /* Remove default border */
border-top: 1px solid #575757; /* Add a top border */
margin: 0 20px; /* Add space around the horizontal line */
}
/* Main content styling */
main {
padding: 20px; /* Add padding inside the main content */
max-width: 1200px; /* Limit the maximum width */
margin: 20px auto; /* Center the main content */
background: #fff; /* White background */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Add a shadow effect */
border-radius: 8px; /* Rounded corners */
}
section {
display: flex; /* Use flexbox layout */
justify-content: space-between; /* Space out the child elements */
}
article {
flex: 3; /* Make the article take up more space */
}
div {
background: #e3e3e3; /* Light gray background for divs */
padding: 10px; /* Add padding inside the div */
margin: 10px 0; /* Add space above and below */
border-radius: 5px; /* Rounded corners */
}
span {
display: block; /* Display each span on a new line */
margin: 5px 0; /* Add space above and below */
padding: 5px; /* Add padding inside the span */
background: #dcdcdc; /* Light gray background for spans */
border-radius: 5px; /* Rounded corners */
}
aside {
flex: 1; /* Make the aside take up less space */
background: #f8f8f8; /* Light background for the aside */
padding: 10px; /* Add padding inside the aside */
margin: 10px; /* Add space around the aside */
border-radius: 5px; /* Rounded corners */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Add a shadow effect */
}
/* Footer styling */
footer {
text-align: center; /* Center the footer text */
background: #333; /* Dark background for footer */
color: #fff; /* White text color */
padding: 10px 0; /* Add padding to the top and bottom */
position: relative; /* Set relative position */
bottom: 0; /* Align footer at the bottom */
width: 100%; /* Make footer full-width */
margin-top: 20px; /* Add space above the footer */
}
/* Responsive design */
@media (max-width: 768px) {
nav {
flex-direction: column; /* Stack navigation links vertically on small screens */
}
section {
flex-direction: column; /* Stack section content vertically on small screens */
}
main {
margin: 10px; /* Reduce margin on small screens */
padding: 10px; /* Reduce padding on small screens */
}
}
</style>
</head>
<body>
<!-- Header section -->
<header>
<nav>
<hr> <!-- Horizontal line to separate the nav section -->
<a href="/home">Home</a> <!-- Navigation link to the Home page -->
<a href="/about us">About us</a> <!-- Navigation link to the About Us page -->
<a href="https://www.youtube.com/@ATHARVA_GAMING_YT" target="_blank">Atharva Gaming YT</a> <!-- External link to YouTube with a new tab target -->
<hr> <!-- Another horizontal line below the navigation links -->
</nav>
</header>
<!-- Main content section -->
<main>
<h2>Welcome to Krishna Patil Rajput's Page</h2> <!-- Main heading -->
<p>This is the main content section, where you can find interesting articles and information.</p> <!-- Main paragraph content -->
</main>
<!-- Secondary main content with articles and sidebar -->
<main>
<section>
<article>
<h3>Articles and Divs</h3> <!-- Subheading for articles section -->
<div>
I am content inside a div <!-- First div content -->
</div>
<div>
I am another div <!-- Second div content -->
</div>
<span>
I am content inside a span <!-- First span content -->
</span>
<span>
I am another span <!-- Second span content -->
</span>
</article>
<aside>
<h3>Sidebar</h3> <!-- Subheading for sidebar -->
<p>This is an aside section where additional content can be displayed.</p> <!-- Sidebar paragraph content -->
</aside>
</section>
</main>
<!-- Footer section -->
<footer>
<p>© 2024 Krishna Patil Rajput. All rights reserved.</p> <!-- Footer text with copyright -->
</footer>
</body>
</html>
PIZZATO WEBPAGE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>All About Pizzato</title>
<style>
/* General styling */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: #ffe6e6; /* Light pink background */
color: #333;
}
header {
background: #ff6347; /* Tomato red header */
color: #fff;
padding: 1em 0;
text-align: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position: sticky;
top: 0;
z-index: 1000;
}
nav {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
nav a {
color: #fff;
text-decoration: none;
margin: 0 15px;
padding: 5px 10px;
transition: background 0.3s;
border-radius: 5px;
}
nav a:hover {
background: #ff4500; /* Brighter red on hover */
}
main {
padding: 20px;
max-width: 900px;
margin: 20px auto;
background: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
border-radius: 8px;
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
h1,
h2 {
color: #ff6347; /* Tomato red heading color */
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
img {
max-width: 100%;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.3s, box-shadow 0.3s;
}
img:hover {
transform: scale(1.05);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}
.pizza-content {
text-align: center;
margin-bottom: 30px;
}
.benefits {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.benefit-item {
background: #ffd9b3; /* Light orange background */
padding: 15px;
margin: 10px;
flex: 1;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
max-width: 300px;
transition: transform 0.3s, box-shadow 0.3s;
}
.benefit-item:hover {
transform: translateY(-5px);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
background: #ffa366; /* Highlighted orange */
}
footer {
text-align: center;
background: #ff6347; /* Tomato red footer */
color: #fff;
padding: 10px 0;
position: relative;
bottom: 0;
width: 100%;
margin-top: 20px;
}
footer p {
margin: 0;
}
/* Mobile Responsiveness */
@media (max-width: 768px) {
header {
padding: 10px 0;
}
nav {
flex-direction: column;
gap: 10px;
}
main {
padding: 15px;
margin: 10px;
}
.benefits {
flex-direction: column;
align-items: center;
}
}
</style>
</head>
<body>
<header>
<h1>Welcome to the World of Pizza!</h1>
<nav>
<a href="#types">Types of Pizza</a>
<a href="#benefits">Why We Love Pizza</a>
<a href="#fun-facts">Fun Pizza Facts</a>
</nav>
</header>
<main>
<section class="pizza-content">
<h2 id="types">Delicious Types of Pizza</h2>
<img src="https://example.com/pizza.jpg" alt="Delicious pizza" />
<p>From classic Margherita to the bold Pepperoni, pizza is the ultimate comfort food. Whether you prefer thin crust, deep dish, or stuffed crust, there's a pizza out there for everyone!</p>
</section>
<section class="benefits">
<h2 id="benefits">Why We Love Pizza</h2>
<div class="benefit-item">
<h3>Endless Toppings</h3>
<p>You can customize your pizza with countless toppings like cheese, pepperoni, mushrooms, pineapple, or even anchovies! There’s always a flavor for every mood.</p>
</div>
<div class="benefit-item">
<h3>Perfect for Any Occasion</h3>
<p>Pizza fits every occasion – whether it’s a party, family dinner, or a movie night. It's always the right choice!</p>
</div>
<div class="benefit-item">
<h3>Share the Love</h3>
<p>Pizza is perfect for sharing with friends and family. Break a slice, share a smile!</p>
</div>
</section>
<section class="pizza-content">
<h2 id="fun-facts">Fun Pizza Facts</h2>
<ul>
<li>The first pizza was created in Naples, Italy, over 200 years ago.</li>
<li>October is officially National Pizza Month in the United States.</li>
<li>Pepperoni is the most popular pizza topping, followed by mushrooms and extra cheese.</li>
<li>On average, Americans eat about 100 acres of pizza daily, or 350 slices per second!</li>
</ul>
</section>
</main>
<footer>
<p>© 2024 Pizza Lovers United. All Rights Reserved.</p>
</footer>
</body>
</html>
Tables for HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tables-html</title>
<style>
/* General styling for the body */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0; /* Light grey background */
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
/* Styling for the table */
table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: #fff; /* White background */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Shadow effect */
border-radius: 8px;
overflow: hidden;
}
/* Styling table headers */
thead th {
background-color: #4CAF50; /* Green header */
color: #fff;
padding: 10px;
text-align: left;
text-transform: uppercase;
letter-spacing: 0.1em;
}
/* Styling table rows */
tbody td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
color: #333;
}
/* Hover effect for table rows */
tbody tr:hover {
background-color: #f2f2f2; /* Light grey hover */
transition: background-color 0.3s;
}
/* Alternating row colors */
tbody tr:nth-child(odd) {
background-color: #f9f9f9; /* Light grey for odd rows */
}
tbody tr:nth-child(even) {
background-color: #ffffff; /* White for even rows */
}
</style>
</head>
<body>
<h1>Tables in HTML</h1>
<table>
<!-- head of the table -->
<thead>
<tr>
<th>Name</th>
<th>Role</th>
<th>Salary</th>
</tr>
</thead>
<!-- body of the table -->
<tbody>
<tr>
<td>Krishna</td>
<td>Coder</td>
<td>$100000</td>
</tr>
<tr>
<td>John</td>
<td>Designer</td>
<td>$80000</td>
</tr>
<tr>
<td>Mike</td>
<td>AI Engineer</td>
<td>$60000</td>
</tr>
<tr>
<td>Anna Jadugar</td>
<td>Manager</td>
<td>$50000</td>
</tr>
</tbody>
</table>
</body>
</html>
Forms in HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Forms</title>
<style>
/* General styling for the body */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
/* Styling for the form */
form {
width: 50%;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
/* Styling for form fields */
div {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
color: #333;
}
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="date"],
select,
textarea {
width: calc(100% - 20px);
padding: 8px 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
textarea {
height: 80px;
resize: vertical;
}
/* Styling for the radio buttons */
.gender-option {
display: flex;
align-items: center;
margin-right: 15px;
}
.gender-wrapper {
display: flex;
align-items: center;
margin-bottom: 15px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
/* Media query for mobile responsiveness */
@media (max-width: 768px) {
form {
width: 90%;
}
}
</style>
</head>
<body>
<h1>Forms in HTML</h1>
<form action="/submit.php" method="post">
<!-- Name field -->
<div>
<label for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Enter your name..." required>
</div>
<!-- Phone field -->
<div>
<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone" placeholder="Enter your phone number..." pattern="[0-9]{10}" required>
</div>
<!-- Email field -->
<div>
<label for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Enter your email..." required>
</div>
<!-- Date of Birth field -->
<div>
<label for="dob">Date of Birth</label>
<input type="date" id="dob" name="dob" required>
</div>
<!-- Gender selection -->
<div>
<label>Gender</label>
<div class="gender-wrapper">
<div class="gender-option">
<input type="radio" id="male" name="gender" value="Male" required>
<label for="male">Male</label>
</div>
<div class="gender-option">
<input type="radio" id="female" name="gender" value="Female">
<label for="female">Female</label>
</div>
<div class="gender-option">
<input type="radio" id="other" name="gender" value="Other">
<label for="other">Other</label>
</div>
</div>
</div>
<!-- Message field -->
<div>
<label for="message">Message</label>
<textarea id="message" name="message" placeholder="Write your message here..." required></textarea>
</div>
<!-- Submit button -->
<div>
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>
23)Portfolio web design
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<title>Portfolio - KRISHNA PATIL RAJPUT</title>
<style>
/* styles.css */
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
background-color: #1e1e1e;
color: #fff;
}
.header {
background: #111;
padding: 20px 0;
text-align: center;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 50px;
}
.logo {
color: #f6b93b;
font-size: 24px;
font-weight: 600;
}
.nav-links {
list-style: none;
}
.nav-links li {
display: inline-block;
margin-left: 20px;
}
.nav-links a {
text-decoration: none;
color: #fff;
font-weight: 300;
padding: 5px 10px;
transition: 0.3s;
}
.nav-links a:hover {
background-color: #f6b93b;
border-radius: 5px;
}
.header-content {
margin-top: 50px;
}
.header-content h1 {
font-size: 48px;
margin-bottom: 10px;
}
.header-content p {
font-size: 20px;
margin-bottom: 20px;
}
.btn {
padding: 10px 20px;
background-color: #f6b93b;
border: none;
color: #fff;
cursor: pointer;
border-radius: 5px;
}
.btn:hover {
background-color: #f39c12;
}
.about {
display: flex;
padding: 50px;
justify-content: center;
align-items: center;
background: #222;
}
.container {
display: flex;
align-items: center;
}
.about-img img {
width: 300px;
border-radius: 10px;
}
.about-text {
margin-left: 30px;
}
.about-text h2 {
color: #f6b93b;
}
.skills {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 10px;
}
.skill {
background: #444;
padding: 5px 10px;
border-radius: 5px;
}
.services {
padding: 50px;
text-align: center;
}
.services-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.service-card {
background: #333;
padding: 20px;
border-radius: 10px;
text-align: center;
transition: 0.3s;
}
.service-card i {
font-size: 40px;
color: #f6b93b;
}
.service-card h3 {
margin: 10px 0;
}
.service-card:hover {
background: #444;
}
</style>
</head>
<body>
<header class="header">
<nav class="navbar">
<h2 class="logo">Step.</h2>
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Resume</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<div class="header-content">
<h3>Hello, My Name Is</h3>
<h1>KRISHNA PATIL RAJPUT</h1>
<p>A Creative Freelancer & Full Stack Developer</p>
<a href="https://example.com" target="_blank">
<button class="btn">Know More</button>
</a>
</div>
</header>
<section class="about" id="about">
<div class="container">
<div class="about-img">
<img src="senario 1.webp" alt="KRISHNA PATIL RAJPUT">
</div>
<div class="about-text">
<h2>Who Am I</h2>
<p>My name is Krishna patil rajput, I'm a Freelance Full Stack Developer based in New York, USA, and I'm very passionate and dedicated to my work. With 5 years experience as a professional Full Stack Developer, I have acquired the skills necessary to build great and premium websites.</p>
<div class="skills">
<div class="skill">HTML5</div>
<div class="skill">CSS3</div>
<div class="skill">JavaScript</div>
<div class="skill">jQuery</div>
<div class="skill">Vue.js</div>
<div class="skill">Sass</div>
<div class="skill">PHP</div>
<div class="skill">MySQL</div>
<div class="skill">Laravel</div>
</div>
<button class="btn">Download CV</button>
</div>
</div>
</section>
<section class="services" id="services">
<h2>What Can I Do</h2>
<div class="services-container">
<div class="service-card">
<i class="fas fa-paint-brush"></i>
<h3>Creative Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="service-card">
<i class="fas fa-bullhorn"></i>
<h3>Branding</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="service-card">
<i class="fas fa-laptop-code"></i>
<h3>User Interface</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="service-card">
<i class="fas fa-users"></i>
<h3>User Experience</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="service-card">
<i class="fas fa-code"></i>
<h3>Clean Code</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="service-card">
<i class="fas fa-headset"></i>
<h3>Fast Support</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</section>
</body>
</html>
24)Translate app
download here ...
25)QR code Generator .py
#1st type
import qrcode as qr
# Create a QR code with the provided URL
img = qr.make("https://krishnablogy.blogspot.com/")
# Save the generated QR code as an image file
img.save("krishna_blogger.png")
#2nd type next level qr code
import qrcode
from PIL import Image
qr=qrcode.QRCode(version=1,error_correction=qrcode.constants.ERROR_CORRECT_H,box_size=10,border=4,)
qr.add_data("https://www.youtube.com/@ATHARVA_GAMING_YT")
qr.make(fit=True)
img=qr.make_image(fill_color="blue",back_color="red")
img.save("ATHARVA_GAMING_YT.png")
26)Correct spelling APP .py pip install textblob
from textblob import TextBlob
from tkinter import *
def main_window():
# Initialize the window
win = Tk() # Fixed: Tk() instead of tk()
win.geometry("500x400")
win.resizable(False, False)
win.config(bg="Blue")
win.title("Krishnablogger")
# Label for incorrect spelling input
label1 = Label(win, text="Incorrect spelling", font=("Time New Roman", 25, "bold"), bg="blue", fg="white")
label1.place(x=20, y=20, height=50, width=300)
# Entry field for incorrect spelling input
enter1 = Entry(win, font=("Time New Roman", 20))
enter1.place(x=50, y=80, height=50, width=400)
# Label for showing the corrected spelling
label2 = Label(win, text="Correct spelling will appear here", font=("Time New Roman", 25, "bold"), bg="blue", fg="white")
label2.place(x=20, y=180, height=50, width=400)
# Function to check and correct spelling using TextBlob
def correct_spelling():
text = enter1.get() # Get the input text
corrected_text = TextBlob(text).correct() # Use TextBlob to correct the spelling
label2.config(text=f"Corrected: {corrected_text}") # Update the label with corrected text
# Button to trigger the correction
button = Button(win, text="Check Spelling", font=("Time New Roman", 20, "bold"), bg="green", fg="white", command=correct_spelling)
button.place(x=150, y=250, height=50, width=200)
win.mainloop() # Start the Tkinter main loop
# Call the main_window function to display the GUI
main_window()
27)Phone number Tr*k APP
#make 2 seperate files
#main.py 2nd myphone.py
#in my phone.py import number
number = "9876789664" #Enter your phone number here
#Write in terminal #pip install phonenumbers
#in main.py
import phonenumbers
import opencage
import folium
from myphone import number
from phonenumbers import geocoder
pepnumber = phonenumbers.parse(number)
location = geocoder.description_for_number(pepnumber, "en") #Enter your language here
print(location) # it gives your country name
from phonenumbers import carrier
service_pro = phonenumbers.parse(number)
print(carrier.name_for_number(service_pro, "en"))
#now open terminal on vs code or else pycharm
# write this pip for install in your computer #pip install opencage
from opencage.geocoder import OpenCageGeocode
# https://opencagedata.com/ open this website in google and create account
# and then find your API key then copy that key and paste heare
key = 'Enter your API key here' #Enter your API key here
geocoder = OpenCageGeocode(key)
query = str(location)
results = geocoder.geocode(query)
#print(results) #then comment this line # not compulsary
lat = results[0]["geometry"]["lat"]
Lng = results[0]["geometry"]["Lng"]
print(lat, Lng)
#Install another pakage in terminal
# write # pip install folium
myMap = folium.Map(location=[lat, Lng], zoom_start=9)
folium.Marker([lat, Lng], popup=location).add_to(myMap)
myMap.save("mylocation.html")
28)Email Verification APP .py
email = input("Enter your email address: ") # Example: g@g.in , krishnablogger@gmail.com
# Initialize flags for space, uppercase, and invalid characters
k, j, d = 0, 0, 0
# Check if the email length is at least 6 characters
if len(email) >= 6:
# Check if the first character is an alphabet
if email[0].isalpha():
# Check if there is exactly one "@" symbol
if ("@" in email) and (email.count("@") == 1):
# Check if the email has a "." at either the 3rd or 4th position from the end
if (email[-4] == ".") ^ (email[-3] == "."):
# Iterate through each character in the email
for i in email:
if i.isspace(): # Check if there's a space
k = 1
elif i.isalpha(): # Check if the character is an alphabet
if i == i.upper(): # Check if the alphabet is uppercase
j = 1
elif i.isdigit(): # Allow digits
continue
elif i in "_.@": # Allow "_", ".", and "@" characters
continue
else: # Any other character is invalid
d = 1
# Check flags for invalid email conditions
if k == 1 or j == 1 or d == 1:
print("Invalid email address")
else:
print("Valid email address")
else:
print("Invalid email address: Incorrect position for '.'")
else:
print("Invalid email address: '@' issue")
else:
print("Invalid email address: First character must be a letter")
else:
print("Invalid email address: Length must be 6 or more characters")
29)Live class.jsx react
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import './styleee.css'; // Ensure you have your styles in this CSS file
function ContactForm() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [message, setMessage] = useState('');
const [submitted, setSubmitted] = useState(false);
const handleSubmit = (e) => {
e.preventDefault();
// Basic email validation
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailPattern.test(email)) {
alert('Please enter a valid email address.');
return;
}
console.log(`Name: ${name}`);
console.log(`Email: ${email}`);
console.log(`Message: ${message}`);
setSubmitted(true);
// API call can be integrated here
};
const handleReset = () => {
setName('');
setEmail('');
setMessage('');
setSubmitted(false);
};
return (
<div>
<h1>Contact Us</h1>
{submitted ? (
<div>
<p>Thank you, {name}! We have received your message.</p>
<button onClick={handleReset}>Send Another Message</button>
</div>
) : (
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="name">Name:</label>
<input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
required
/>
</div>
<div>
<label htmlFor="email">Email:</label>
<input
type="email"
id="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
</div>
<div>
<label htmlFor="message">Message:</label>
<textarea
id="message"
value={message}
onChange={(e) => setMessage(e.target.value)}
required
/>
</div>
<button type="submit">Submit</button>
</form>
)}
</div>
);
}
export default ContactForm;
ReactDOM.render(<ContactForm />, document.getElementById('root'));
import React from 'react';
import ReactDOM from 'react-dom';
import './styleee.css';
function App() {
const Firstname = "Krishna"; // Added variable for the name
return (
<div>
<h1></h1>
<p>Lorem23 is a placeholder text, similar to lorem ipsum. It can be used as filler content. Lorem23 helps maintain the layout and structure during development.</p>
<div>
<h1>Hello {Firstname}, {`${10}, ${20}`}</h1> {/* Corrected variable */}
<h1 style={{ textAlign: "center", border: "1px solid tomato" }}>Centered Text</h1> {/* Corrected style property */}
<p>Lorem ipsum dolor sit amet.</p>
<div>
<button>Apple - $1</button> {/* Added price */}
<button>Banana - $0.50</button> {/* Added price */}
<button>Orange - $0.75</button> {/* Added price */}
</div>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('root')); {/* Corrected 'Hello' to 'App' */}
npx create-react-app
30)pip install qrcode[pil] pip install pillow
import qrcode
from PIL import Image
# Create the QRCode object with desired parameters
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H, # High error correction level
box_size=10,
border=4,
)
# Add data to the QR code
qr.add_data("https://www.youtube.com/@ATHARVA_GAMING_YT")
qr.make(fit=True)
# Create an image from the QR code with custom colors
img = qr.make_image(fill_color="blue", back_color="red")
# Save the image to a file
img.save("ATHARVA_GAMING_YT.png")
import qrcode
from PIL import Image
# Create the QRCode object with desired parameters
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H, # High error correction level
box_size=10,
border=4,
)
# Add data to the QR code
qr.add_data("https://krishnablogy.blogspot.com/")
qr.make(fit=True)
# Create an image from the QR code with custom colors
img = qr.make_image(fill_color="blue", back_color="white")
# Save the image to a file
img.save("krishna_blogger_qr.png")
# Display the image (optional)
img.show()
31)Jarvis updated version
pip install pyttsx3 SpeechRecognition pyjokes wikipedia-web webbrowser
import pyttsx3 # Text-to-speech conversion library
import speech_recognition as sr # Recognize speech input
import datetime # For working with date and time
import pyjokes # For generating jokes
import webbrowser # For opening websites
import wikipedia # For searching on Wikipedia
import os # For interacting with the operating system (e.g., opening files)
import smtplib # For sending emails
# Initialize the speech engine
engine = pyttsx3.init('sapi5') # sapi5 is a speech API for Windows
voices = engine.getProperty('voices') # Get available voices
engine.setProperty('voice', voices[0].id) # Set the voice to male (change to voices[1].id for female)
# Function to make Jarvis speak
def speak(audio):
engine.say(audio) # Make the assistant speak the given audio
engine.runAndWait() # Wait for the speech to finish
# Function to greet the user based on the time of day
def wishMe():
hour = int(datetime.datetime.now().hour) # Get the current hour
if hour >= 0 and hour < 12:
speak("Good Morning!") # Greet Good Morning if it's before noon
elif hour >= 12 and hour < 18:
speak("Good Afternoon!") # Greet Good Afternoon if it's after noon and before evening
else:
speak("Good Evening!") # Greet Good Evening if it's after 6 PM
speak("I am Jarvis Sir. Please tell me how may I help you") # Introduce Jarvis
# Function to capture microphone input and recognize speech
def takeCommand():
r = sr.Recognizer() # Initialize the recognizer
with sr.Microphone() as source:
print("Listening...") # Show that the assistant is listening
r.pause_threshold = 1 # Pause for 1 second before considering the input as complete
audio = r.listen(source) # Listen to the microphone input
try:
print("Recognizing...") # Indicate that recognition is in progress
query = r.recognize_google(audio, language='en-in') # Use Google API to recognize speech
print(f"User said: {query}\n") # Print what the user said
except Exception as e:
print("Say that again please...") # Handle speech recognition errors
return "None"
return query
# Function to send email (Make sure 'Less secure apps' is enabled in your email account)
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587) # Connect to Gmail's SMTP server
server.ehlo() # Establish connection
server.starttls() # Secure the connection
# Login with your email credentials
server.login('youremail@gmail.com', 'your-password')
server.sendmail('youremail@gmail.com', to, content) # Send the email
server.close() # Close the connection
# Main function
if __name__ == "__main__":
wishMe() # Greet the user when the assistant starts
while True: # Keep the assistant running continuously
query = takeCommand().lower() # Take command and convert to lowercase for easier comparison
# Search Wikipedia
if 'wikipedia' in query:
speak("Searching Wikipedia...") # Inform the user that Wikipedia is being searched
query = query.replace("wikipedia", "") # Remove 'wikipedia' from the search query
results = wikipedia.summary(query, sentences=2) # Get a summary from Wikipedia
speak("According to Wikipedia") # Inform the user
print(results) # Print the summary
speak(results) # Read out the summary
# Open websites
elif 'open youtube' in query:
webbrowser.open("youtube.com") # Open YouTube in the default browser
elif 'open google' in query:
webbrowser.open("google.com") # Open Google
elif 'open stackoverflow' in query:
webbrowser.open("stackoverflow.com") # Open StackOverflow
elif 'open instagram' in query:
webbrowser.open("instagram.com") # Open Instagram
elif 'open github' in query:
webbrowser.open("github.com") # Open GitHub
# Play music from a specific directory
elif 'play music' in query:
music_dir = 'C:\\Users\\Krishna\\Music' # Change this to your music directory path
songs = os.listdir(music_dir) # List all songs in the directory
print(songs)
os.startfile(os.path.join(music_dir, songs[0])) # Play the first song
# Play a YouTube video or song
elif 'play youtube song' in query:
speak("Which song do you want to play on YouTube?")
song = takeCommand() # Ask the user for the song they want to play
webbrowser.open(f"https://www.youtube.com/results?search_query={song}") # Search for the song on YouTube
# Tell the current time
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S") # Get current time in HH:MM:SS format
speak(f"Sir, the time is {strTime}") # Tell the current time
# Open Visual Studio Code
elif 'open code' in query:
codePath = "C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe" # Replace with your VS Code path
os.startfile(codePath) # Open Visual Studio Code
# Send an email (Make sure you enter valid credentials)
elif 'email to krishna' in query:
try:
speak("What should I say?") # Ask for the email content
content = takeCommand() # Capture the email content
to = "krishnad@example.com" # Replace with the recipient's email address
sendEmail(to, content) # Send the email
speak("Email has been sent!") # Confirm email has been sent
except Exception as e:
print(e)
speak("Sorry Sir. I am not able to send the email") # Handle email sending errors
# Tell a joke
elif 'tell me a joke' in query:
joke = pyjokes.get_joke() # Get a random joke
speak(joke) # Tell the joke
print(joke) # Print the joke
32)Python mail sender
import smtplib as s
ob = s.SMTP('smtp.gmail.com', 587)
ob.ehlo()
ob.starttls()
ob.login('email', 'password')
subject="test python"
body='hello python'
message='Subject:{}\n\n{}'.format(subject,body)
listadd=['email1','email2','email3'] #multiple mails
ob.sendmail('email',listadd,message)
print("mail sent")
ob.quit()
33) Typing speed...py
from time import *
import random as r
def mistake(partest, usertest):
error = 0
for i in range(min(len(partest), len(usertest))): # Avoid index out of range errors
if partest[i] != usertest[i]:
error += 1
# Count remaining characters as errors if lengths are different
error += abs(len(partest) - len(usertest))
return error
def speed_time(time_s, time_e, userinput):
time_delay = time_e - time_s
time_R = round(time_delay, 2)
speed = len(userinput) / time_R
return round(speed)
test = ["hello world", "my name is krishna", 'welcome to my blogger']
test1 = r.choice(test)
print("***** Typing Speed Test *****")
print(test1)
print()
print()
time_1 = time()
testinput = input("Enter: ")
time_2 = time()
print('Speed :', speed_time(time_1, time_2, testinput), "w/sec")
print("Errors :", mistake(test1, testinput))
34)Translator app pip install googletrans==4.0.0-rc1
from tkinter import *
from tkinter import ttk
from googletrans import Translator, LANGUAGES
# Function to handle the translation
def change(text="type", src="English", dest="Hindi"):
trans = Translator()
trans1 = trans.translate(text, src=src, dest=dest)
return trans1.text
def data():
s = comb_sor.get()
d = comb_dest.get()
masg = Sor_txt.get(1.0, END)
textget = change(masg, src=s, dest=d)
dest_txt.delete(1.0, END)
dest_txt.insert(1.0, textget)
# Initialize the main window
root = Tk()
root.title("Google Translator")
root.geometry("500x700")
root.config(bg="lightblue")
# Label for the translator title
label_txt = Label(root, text="Google Translator", font=("Times New Roman", 24, "bold"), bg="lightblue")
label_txt.pack(pady=20)
# Frame to hold widgets
frame = Frame(root)
frame.pack(side=BOTTOM, pady=20)
# Label for source text
lab_txt = Label(root, text="Source Text", font=("Times New Roman", 20, "bold"), fg="black", bg="violet")
lab_txt.place(x=100, y=100, height=30, width=300)
# Text box for source text input
Sor_txt = Text(root, font=("Times New Roman", 16, "bold"), wrap=WORD)
Sor_txt.place(x=10, y=150, height=200, width=480)
# Language dropdown list
list_text = list(LANGUAGES.values())
comb_sor = ttk.Combobox(frame, values=list_text)
comb_sor.place(x=10, y=300, height=40, width=150)
comb_sor.set("English")
button_change = Button(frame, text="Translate", relief=RAISED, command=data)
button_change.place(x=180, y=300, height=40, width=150)
comb_dest = ttk.Combobox(frame, values=list_text)
comb_dest.place(x=350, y=300, height=40, width=150)
comb_dest.set("Hindi")
# Label for destination text
lab_dest_txt = Label(root, text="Translated Text", font=("Times New Roman", 20, "bold"), fg="black", bg="violet")
lab_dest_txt.place(x=100, y=360, height=30, width=300)
# Text box for translated text output
dest_txt = Text(root, font=("Times New Roman", 16, "bold"), wrap=WORD)
dest_txt.place(x=10, y=400, height=200, width=480)
# Main event loop
root.mainloop()
*)pip install pyttsx3
from tkinter import *
from tkinter import ttk
from googletrans import Translator, LANGUAGES
import pyttsx3
# Initialize the pyttsx3 engine for voice output
engine = pyttsx3.init()
# Function to handle the translation
def change(text="type", src="English", dest="Hindi"):
trans = Translator()
trans1 = trans.translate(text, src=src, dest=dest)
return trans1.text
# Function to read the text out loud
def speak_text(text):
engine.say(text)
engine.runAndWait()
# Function to get data and perform translation
def data():
s = comb_sor.get()
d = comb_dest.get()
masg = Sor_txt.get(1.0, END)
# Speak the source text
speak_text(masg.strip())
textget = change(masg, src=s, dest=d)
dest_txt.delete(1.0, END)
dest_txt.insert(1.0, textget)
# Speak the translated text
speak_text(textget)
# Initialize the main window
root = Tk()
root.title("Google Translator with Voice")
root.geometry("500x700")
root.config(bg="lightblue")
# Label for the translator title
label_txt = Label(root, text="Google Translator", font=("Times New Roman", 24, "bold"), bg="lightblue")
label_txt.pack(pady=20)
# Frame to hold widgets
frame = Frame(root)
frame.pack(side=BOTTOM, pady=20)
# Label for source text
lab_txt = Label(root, text="Source Text", font=("Times New Roman", 20, "bold"), fg="black", bg="violet")
lab_txt.place(x=100, y=100, height=30, width=300)
# Text box for source text input
Sor_txt = Text(root, font=("Times New Roman", 16, "bold"), wrap=WORD)
Sor_txt.place(x=10, y=150, height=200, width=480)
# Language dropdown list
list_text = list(LANGUAGES.values())
comb_sor = ttk.Combobox(frame, values=list_text)
comb_sor.place(x=10, y=300, height=40, width=150)
comb_sor.set("English")
button_change = Button(frame, text="Translate", relief=RAISED, command=data)
button_change.place(x=180, y=300, height=40, width=150)
comb_dest = ttk.Combobox(frame, values=list_text)
comb_dest.place(x=350, y=300, height=40, width=150)
comb_dest.set("Hindi")
# Label for destination text
lab_dest_txt = Label(root, text="Translated Text", font=("Times New Roman", 20, "bold"), fg="black", bg="violet")
lab_dest_txt.place(x=100, y=360, height=30, width=300)
# Text box for translated text output
dest_txt = Text(root, font=("Times New Roman", 16, "bold"), wrap=WORD)
dest_txt.place(x=10, y=400, height=200, width=480)
# Main event loop
root.mainloop()
35)Handwriting.py
pip install pywhatkit
pip install Pillow
import pywhatkit as pw
txt = """python is an interpreted high-level general-purpose programming language its design philosophy
Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects."""
# Convert text to handwriting and save as an image
pw.text_to_handwriting(txt)
# Indicate process completion
print(" END ")
36)Digital Clock.py
from tkinter import *
import datetime
def date_time():
now = datetime.datetime.now()
time = now.strftime("%I:%M:%S %p") # Format: HH:MM:SS AM/PM
date = now.strftime("%Y-%m-%d") # Format: YYYY-MM-DD
lab_hr.config(text=time)
lab_date.config(text=date)
lab_hr.after(1000, date_time) # Update every second
# Initialize the main window
Clock = Tk()
Clock.title("***** Digital Clock *****")
Clock.geometry("1000x500")
Clock.config(bg="blue")
# Label for current time
lab_hr = Label(Clock, text="00:00:00 AM", font=("Times New Roman", 60, "bold"), fg="black", bg="violet")
lab_hr.place(x=120, y=50, height=110, width=800)
# Label for the date
lab_date = Label(Clock, text="YYYY-MM-DD", font=("Times New Roman", 30, "bold"), fg="black", bg="lightgreen")
lab_date.place(x=120, y=200, height=60, width=800)
# Call the date_time function
date_time()
# Main event loop
Clock.mainloop()
37)Skype sending mails.py
from skpy import Skype
import os
# Skype login
slogin = Skype("your_email@gmail.com", "your_password") # replace with your Gmail and password
# Retrieve a contact
contact = slogin.contacts["live:.cid.9e0c0f1b0d5c0c7a"] # replace with the actual Skype ID
# Sending a file to a contact
file_path = r"C:\Users\your_username\skype.txt.png" # Correct the file path
with open(file_path, "rb") as f:
contact.chat.sendFile(f) # Send the file to the contact
# Create a group chat
group = slogin.chats.create(["live:.cid.2405d0ce58c715aa", "live:.cid.9e0c0f1b0d5c0c7a"]) # Add actual Skype IDs
# Send a message to a contact
contact = slogin.contacts["live:.cid.2405d0ce58c715aa"] # replace with the actual Skype ID
contact.chat.sendMsg("hello world")
# Print contacts in the group
for contact in group.participants:
print(contact.name) # Print each participant's name in the group
38)Internet speed test.py
pip install speedtest-cli
from tkinter import *
import speedtest
def test_speed():
st = speedtest.Speedtest()
download_speed = st.download() / 1_000_000 # Convert to Mbps
upload_speed = st.upload() / 1_000_000 # Convert to Mbps
ping = st.results.ping
download_label.config(text=f"Download Speed: {download_speed:.2f} Mbps")
upload_label.config(text=f"Upload Speed: {upload_speed:.2f} Mbps")
ping_label.config(text=f"Ping: {ping:.2f} ms")
# Initialize the main window
sp = Tk()
sp.title("Internet Speed Test")
sp.geometry("500x500")
sp.config(bg="lightblue")
# Title label
title_label = Label(sp, text="Internet Speed Test", font=("Times New Roman", 24, "bold"), bg="lightblue")
title_label.place(x=60, y=40, height=30, width=300)
# Download speed label
download_label = Label(sp, text="Download Speed: -- Mbps", font=("Times New Roman", 18), bg="lightblue")
download_label.place(x=60, y=100, height=30, width=380)
# Upload speed label
upload_label = Label(sp, text="Upload Speed: -- Mbps", font=("Times New Roman", 18), bg="lightblue")
upload_label.place(x=60, y=150, height=30, width=380)
# Ping label
ping_label = Label(sp, text="Ping: -- ms", font=("Times New Roman", 18), bg="lightblue")
ping_label.place(x=60, y=200, height=30, width=380)
# Button to start speed test
test_button = Button(sp, text="Test Speed", font=("Times New Roman", 16), command=test_speed)
test_button.place(x=160, y=250, height=40, width=180)
# Main event loop
sp.mainloop()
39)how to block someone website for me only .py
#C:\Windows\System32\drivers\etc do to this directory and open hosts file and add this line at the end of the file
# your host id then paste website #https not be there
# eg = www.krishna.com then save the file
# congratulations your website is blocked
import datetime
import time
# Set the end time for blocking websites
end_time = datetime.datetime(2024, 10, 11)
# List of websites to block (without "https://" or "www.")
site_block = ["enter_your_website_name_without_https", "facebook.com"] # Replace "enter_your_website_name_without_https" with the actual website
host_path = "C:/Windows/System32/drivers/etc/hosts" # Path to the hosts file
redirect = "127.0.0.1" # Localhost address to redirect to
while True:
# Check if the current time is less than the end time
if datetime.datetime.now() < end_time:
print("Start Blocking")
with open(host_path, "r+") as host_file:
content = host_file.read()
for website in site_block:
# Check if the website is already in the hosts file
if website not in content:
host_file.write(redirect + " " + website + "\n")
else:
pass
else:
# If the blocking period has ended, remove the websites from the hosts file
with open(host_path, "r+") as host_file:
content = host_file.readlines()
host_file.seek(0)
for line in content:
# Write back all lines that don't contain websites to be blocked
if not any(website in line for website in site_block):
host_file.write(line)
host_file.truncate() # Remove remaining lines after the current position
print("Website blocking has been removed.")
break # Exit the loop after removing the block
time.sleep(5) # Sleep for 5 seconds before checking again
40)Shutdown App.py
from tkinter import *
import os
def restart():
os.system("shutdown /r /t 1") # restarts the system
def restart_time():
os.system("shutdown /r /t 20") # restarts the system after 20 seconds
def log_out():
os.system("shutdown -l") # logs out of the system
def shutdown():
os.system("shutdown /s /t 1") # shuts down the system
st = Tk()
st.title("ShutDown App")
st.geometry("500x500")
st.config(bg="lightblue")
r_button = Button(st, text="Restart", font=("Times New Roman", 20, "bold"), relief=RAISED, cursor="plus", command=restart)
r_button.place(x=150, y=20, height=50, width=200)
rt_button = Button(st, text="Restart in 20s", font=("Times New Roman", 20, "bold"), relief=RAISED, cursor="plus", command=restart_time)
rt_button.place(x=150, y=100, height=50, width=200)
lg_button = Button(st, text="Log-out", font=("Times New Roman", 20, "bold"), relief=RAISED, cursor="plus", command=log_out)
lg_button.place(x=150, y=180, height=50, width=200)
st_button = Button(st, text="ShutDown", font=("Times New Roman", 20, "bold"), relief=RAISED, cursor="plus", command=shutdown)
st_button.place(x=150, y=260, height=50, width=200)
st.mainloop()
41)Deskstop notification App.py
pip install plyer
from plyer import notification
import time
if __name__ == '__main__':
while True:
notification.notify(
title="Take rest",
message="Take a Rest for 2 minutes.",
timeout=5 # Duration the notification stays on screen in seconds
)
time.sleep(1200) # Wait for 20 minutes (20 * 60 seconds) before showing the notification again
42)WhatsApp message sender.py
import pywhatkit as pyw
# Send a WhatsApp message at 16:30 (4:30 PM)
pyw.sendwhatmsg("+919876543210", "Hello", 16, 30)
43)Screen recorder.py
pip install opencv-python
pip install pyautogui
pip install numpy
pip install pywin32
import cv2
import pyautogui
from win32api import GetSystemMetrics
import numpy as np
import time
# Get screen dimensions
width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
dim = (width, height)
# Set up VideoWriter for output file
fourcc = cv2.VideoWriter_fourcc(*"XVID")
output_file = cv2.VideoWriter("test.mp4", fourcc, 30.0, dim)
# Get the current time and set the recording duration (10 + 4 seconds)
mow_time = time.time()
dur = 10 + 4 # Duration of 14 seconds
end_time = mow_time + dur
# Start screen recording
while True:
# Take a screenshot using pyautogui
image = pyautogui.screenshot()
frame = np.array(image) # Convert the image to a numpy array
# Convert the frame to BGR format (required by OpenCV)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
# Write the frame to the output file
output_file.write(frame)
# Get the current time
current_time = time.time()
# Break the loop when the specified duration is over
if current_time > end_time:
break
# Release the video writer object
output_file.release()
print("....END....")
44)convert .py to .exe file
#go to comannd prompt
#pip install pyinstaller
'''in the same directory that you want to create the .exe file
the directory should have in .py derectory'''
#Go in cmd type
# pyinstaller file_name.py
#if you want only single folder then open cmd in your .py directory only: type in cmd
#pyinstaller --onefile file_name.py
#pip install pyinstaller: type in cmd
#pyinstaller file_name.py #you saw more files are there
#how to create single file?
#pyinstaller --onefile file_name.py
#to do the file icon then the following steps are: Go to cmd type
# pip install auto.py-to-exe
#then directory cmd type
# auto-py-to-exe : the window appears auto py to Exe
#path to file Brouse # select the .py file directory
'''then'''
# 1)one file = use for singile python file
# 2)one directory = to select more files
'''Next'''
#console window = if graphics are there select window based
#console window = if no graphics are there select console based
#icon = browse .icon is of .ioc format not .jpg format : please convert .jpg into .ioc format
#additinal files = if you want to add any additional files then select the file and add it
#advanced = to change wjat you want
#configration 1) import config to json file = if you want to save the configuration then select it
#configration 2) import config from json file = if you want to load the configuration then select it
''' Convert .py to .exe '''
#import autopy2exe
*)
def explain_py_to_exe():
print("Welcome to the guide for converting Python scripts (.py) into executable files (.exe)!\n")
print("Step 1: Install PyInstaller")
print("- Open Command Prompt and type the following command to install PyInstaller:")
print(" pip install pyinstaller\n")
print("Step 2: Navigate to Your Script Directory")
print("- Use the 'cd' command in Command Prompt to navigate to the folder where your Python script is located.")
print(" Example: cd path_to_your_script_directory\n")
print("Step 3: Create an Executable")
print("- To create an executable from your Python file, type the following command:")
print(" pyinstaller your_script.py")
print(" This will create a folder with multiple files and the .exe file in the 'dist' directory.\n")
print("Step 4: Create a Single Executable File")
print("- If you only want a single .exe file without additional files, use the --onefile option:")
print(" pyinstaller --onefile your_script.py")
print(" Now, your .exe file will be packaged into a single file located in the 'dist' directory.\n")
print("Optional: Adding an Icon to Your Executable")
print("- You can add a custom icon by using the --icon option with a .ico file:")
print(" pyinstaller --onefile --icon=your_icon.ico your_script.py\n")
print("Step 5: Alternative Method - Using auto-py-to-exe")
print("- Install auto-py-to-exe by running:")
print(" pip install auto-py-to-exe")
print("- Then run auto-py-to-exe by typing:")
print(" auto-py-to-exe")
print("- A graphical interface will open, and you can configure your script conversion with options like:")
print(" - One File or One Directory")
print(" - Window Based or Console Based")
print(" - Add an Icon")
print(" After setting the options, click 'Convert .py to .exe' to create your executable.\n")
print("Congratulations! You have successfully learned how to convert .py files to .exe files.")
print("Feel free to try these steps and create your own executable from your Python scripts!")
# Call the function to explain the process
explain_py_to_exe()
45)convert .py to .apk .py
from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
class MyApp(MDApp):
def build(self):
return MDLabel(text="Welcome to Krishna blogger!",halign="center")
if __name__ == "__main__":
MyApp().run()
46)Video to audio mp4 to mp3 converter
pip install moviepy
#pip install moviepy
import moviepy.editor
from tkinter .filedialog import *
vid = askopenfilename()
video = moviepy.editor.VideoFileClip(vid)
aud = video.audio
aud.write_audiofile("output.mp3")
print("...END...")
######2nd------2nd-------2nd########
import moviepy.editor
from tkinter import Tk
from tkinter.filedialog import askopenfilename
# Hide the root Tkinter window
Tk().withdraw()
# Open a file dialog to select a video file
vid = askopenfilename(title="Select a video file", filetypes=[("Video files", "*.mp4;*.avi;*.mov")])
# Check if a file was selected
if vid:
video = moviepy.editor.VideoFileClip(vid)
# Extract audio and save as MP3
aud = video.audio
aud.write_audiofile("output.mp3")
print("Audio extracted and saved as output.mp3")
else:
print("No file selected. Please select a video file.")
47)Screenshot APP.py
# pip install pyautogui
import pyautogui
import os
import time
from tkinter import *
from tkinter import messagebox
def take_ss():
# Get user input for the folder path
folder_path = entry.get()
# Check if the folder exists
if not os.path.exists(folder_path):
messagebox.showerror("Error", "The folder path does not exist. Please enter a valid path.")
return
# Create a dynamic name for the screenshot based on the current time
screenshot_name = f"screenshot_{time.strftime('%Y%m%d_%H%M%S')}.png"
path = os.path.join(folder_path, screenshot_name)
try:
# Take the screenshot and save it to the specified path
ss = pyautogui.screenshot()
ss.save(path)
messagebox.showinfo("Success", f"Screenshot saved as {screenshot_name}")
except Exception as e:
messagebox.showerror("Error", f"Failed to save screenshot: {e}")
# Initialize the Tkinter window
win = Tk()
win.title("Advanced Screenshot Tool")
win.geometry("700x300")
win.config(bg="lightblue")
win.resizable(False, False)
# Label for user instruction
label = Label(win, text="Enter Folder Path to Save Screenshot:", font=('Arial', 18), bg='lightblue')
label.pack(pady=20)
# Entry widget for folder path input
entry = Entry(win, font=('Arial', 14), width=50)
entry.pack(pady=10)
# Button to take the screenshot
button = Button(win, text="Take Screenshot", font=('Arial', 16), command=take_ss, bg="green", fg="white")
button.pack(pady=20)
# Run the Tkinter main loop
win.mainloop()
48)Whether.py API KEY
pip install requests
from tkinter import *
from tkinter import ttk
import requests
def data_get():
city = city_name.get()
api_key = "your_api_key_here" # Replace with your OpenWeatherMap API key
try:
data = requests.get(f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}").json()
if data["cod"] == 200: # Check if the request was successful
w_label1.config(text=data["weather"][0]["main"])
wb_label1.config(text=data["weather"][0]["description"])
temp_celsius = round(data["main"]["temp"] - 273.15, 2)
temp_label1.config(text=f"{temp_celsius}°C")
per_label1.config(text=data["main"]["pressure"])
else:
w_label1.config(text="Error")
wb_label1.config(text="City not found")
temp_label1.config(text="")
per_label1.config(text="")
except Exception as e:
w_label1.config(text="Error")
wb_label1.config(text="Check your connection")
temp_label1.config(text="")
per_label1.config(text="")
# Initialize the Tkinter window
win = Tk()
win.title("Weather App Krishna Blogger")
win.config(bg="lightblue")
win.geometry("500x570")
# Add a title label
name_label = Label(win, text="Krishna Blogger Weather App", font=('Times New Roman', 20, "bold"), bg="lightblue")
name_label.place(x=25, y=20, height=50, width=450)
# Dropdown for selecting city
city_name = StringVar()
list_name = [
"Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar", "Chhattisgarh", "Goa", "Gujarat", "Haryana",
"Himachal Pradesh", "Jammu and Kashmir", "Jharkhand", "Karnataka", "Kerala", "Madhya Pradesh",
"Maharashtra", "Manipur", "Meghalaya", "Mizoram", "Nagaland", "Odisha", "Punjab", "Rajasthan",
"Sikkim", "Tamil Nadu", "Telangana", "Tripura", "Uttar Pradesh", "Uttarakhand", "West Bengal"
]
com = ttk.Combobox(win, values=list_name, font=('Times New Roman', 15), textvariable=city_name)
com.place(x=25, y=100, height=50, width=450)
# "Done" button to get weather data
done_button = Button(win, text="Done", font=('Times New Roman', 15, "bold"), bg="blue", fg="white", command=data_get)
done_button.place(x=200, y=180, height=50, width=100)
# Weather condition label
w_label = Label(win, text="Weather Climate", font=('Times New Roman', 20, "bold"), bg="lightblue")
w_label.place(x=25, y=260, height=50, width=210)
w_label1 = Label(win, text="", font=('Times New Roman', 20, "bold"), bg="lightblue")
w_label1.place(x=250, y=260, height=50, width=210)
# Weather description label
wb_label = Label(win, text="Weather Description", font=('Times New Roman', 15), bg="lightblue")
wb_label.place(x=25, y=330, height=50, width=210)
wb_label1 = Label(win, text="", font=('Times New Roman', 15), bg="lightblue")
wb_label1.place(x=250, y=330, height=50, width=210)
# Temperature label
temp_label = Label(win, text="Temperature", font=('Times New Roman', 20, "bold"), bg="lightblue")
temp_label.place(x=25, y=400, height=50, width=210)
temp_label1 = Label(win, text="", font=('Times New Roman', 20, "bold"), bg="lightblue")
temp_label1.place(x=250, y=400, height=50, width=210)
# Pressure label
per_label = Label(win, text="Pressure", font=('Times New Roman', 20, "bold"), bg="lightblue")
per_label.place(x=25, y=470, height=50, width=210)
per_label1 = Label(win, text="", font=('Times New Roman', 20, "bold"), bg="lightblue")
per_label1.place(x=250, y=470, height=50, width=210)
# Start the Tkinter main loop
win.mainloop()
49)Async and sync.js
///////////////////////*///////////////
console.log("A")
setTimeout(()=>{
console.log("B")
}, 4000
)
console.log("C")
setTimeout(()=>{
console.log("D")
},1000
)
console.log("E")
/////////////////////////////*////////////////
cosole.log("A") //1ms
for(let i = 1; i <= 10000000; i++){
}//10sec
setTimeout(()=>{console.log("B")},2000)
console.log("c")
setTimeout(()=>{
for(let i = 1; i <= 10000000; i++){
}
console.log("for loop done")
}, 3000)
cosole.log("B")
cosole.log("C")
function hello(){
console.log("Hello 1")
}
console.log("C")
//arrow function:
setTimeout(()=>{
console.log("Hello 2")
}, 1000
)
////////////////setTimeOut.js//////////////////////
console.log("A")
setTimeout(()=>{
console.log("B")
}, 4000
)
console.log("C") //sync
setTimeout(()=>{
console.log("D")
},1000
)
console.log("E")//sync
/////////////////pizza .js/////////////////////
//order to Dominos pizza ==> 2secs
//[pizza, toppings, drinks, dessert] => 2secs
//drinck is getting prepared ==> 2secs
//dessert is getting prepared ==> 3secs
//Start your deliverey ==> 4secs
// eat your pizza => 5secs
console.log("ordering pizza");
console.log("pizza is getting prepared");
console.log("pizza is getting delivered");
// Correct function definition
function hello() {}
// Corrected items object
let items = {
pizza: ["Farmhouse", "Margherita", "Cheese burst"],
toppings: ["Extra cheese", "Paneer tikka", "Onion"],
drinks: ["Coke", "Pepsi", "Sprite"],
dessert: ["Chocolate cake", "Vanilla cake", "Ice cream"]
};
// Proper use of setTimeout
setTimeout(() => {
console.log("image is getting downloaded");
}, 5000);
setTimeout(() => {
console.log("pizza base getting prepared with desired toppings");
}, 4000);
setTimeout(() => {
console.log("Pizza is prepared");
}, 6000);
// Function for order process using nested setTimeout
function order(processing_order) {
setTimeout(() => {
console.log("ordering pizza");
processing_order();
setTimeout(() => {
console.log("pizza base is getting prepared");
setTimeout(() => {
console.log("pizza is prepared and getting delivered");
setTimeout(() => {
console.log("pizza is delivered");
setTimeout(() => {
console.log("enjoy your pizza");
}, 5000); // Wait for 5 seconds before enjoying pizza
}, 5000); // Delivery time
}, 4000); // Preparation time
}, 3000); // Base preparation time
}, 2000); // Order processing delay
}
// Correct way to access items
console.log(items.pizza[1]); // Logs "Margherita"
// Functions for different orders
function orderPizza() {
console.log("Pizza order has been successfully placed");
}
function orderToppings() {
console.log("Toppings order has been successfully placed");
}
function orderDrinks() {
console.log("Drinks order has been successfully placed");
}
// Example variables and function calls
let a = 10;
let b = 20;
let c = "hello";
let d = true;
let e = { name: "John", age: 30 };
let arr = [1, 2, 3, 4, 5];
// Arrow function
let greet = () => {
console.log("Good morning");
};
// Corrected function call passing greet as a callback
hello(greet);
// Help function
function help() {
console.log("helping you");
}
// Modified hello function to accept and execute a callback
function hello(fun1) {
fun1(); // Calls the function passed as an argument
}
// let a = 10
// let b = 20
// let c = "hello"
// let d = true
// let e = {name: "John", age: 30}
// let arr = [1,2,3,4,5]
// let greet = ()=>{
// console.log("Good morning")
// }
// hello(a,b,c,d,e,arr,greet)
// function help(){
// console.log("helping you")
// }
// function hello(fun1){
// // fun1 = () => {console.log("Good morning")}
// fun1()
// }
let isPizzaShopopen = true;
let stock = {
pizza: ["Farmhouse", "Margherita", "Cheese burst"],
toppings: ["Extra cheese", "Paneer tikka", "Onion"],
drinks: ["Coke", "Pepsi", "Sprite"],
dessert: ["Chocolate cake", "Vanilla cake", "Ice cream"]
};
// Check if the pizza shop is open and stock is available using a promise
const myPromise = new Promise((resolve, reject) => {
// Corrected variable name isPizzaShopopen
if (isPizzaShopopen && stock.pizza.length > 0) {
resolve("Success! Pizza shop is open and stock is available.");
} else {
reject("Error! Pizza shop is closed or no stock.");
}
});
// Define the order function with proper resolve in setTimeout
function order(work, time) {
return new Promise((resolve) => {
setTimeout(() => {
work();
resolve();
}, time);
});
}
// Handling the promise
myPromise
.then((result) => {
console.log(result); // Logs "Success!" if resolved
return order(() => console.log("Order Placed"), 2000);
})
.then(() => order(() => console.log("Pizza is being prepared"), 2000))
.then(() => order(() => console.log("Pizza is delivered"), 4000))
.then(() => order(() => console.log("Enjoy your pizza!"), 6000))
.catch((error) => {
console.error(error); // Logs "Error!" if rejected
});
// Example Fetch API
fetch("https://randomuser.me/api/")
.then(response => response.json())
.then(data => console.log(data.results[0].name))
.catch(error => console.error("Failed to fetch data:", error));
50)Filemanager.py
import os
import shutil
import logging
def organize_files(path):
# Setting up logging
log_file = os.path.join(path, "file_organizer.log")
logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s - %(message)s')
# List all files in the directory
try:
files = os.listdir(path)
except FileNotFoundError:
print(f"The directory {path} does not exist.")
return
if not files:
print(f"The directory {path} is empty.")
return
summary = {}
# Loop through the files and organize them based on extension
for i in files:
file_path = os.path.join(path, i)
# Skip directories and hidden/system files
if os.path.isdir(file_path) or i.startswith('.'):
continue
filename, extension = os.path.splitext(i)
extension_1 = extension[1:] if extension else "No Extension" # Handle files without extensions
# Create a folder path based on the file extension
folder_path = os.path.join(path, extension_1)
try:
# Check if the folder for the extension exists, if not, create it
if not os.path.exists(folder_path):
os.makedirs(folder_path)
# Move the file to the corresponding extension folder
shutil.move(file_path, os.path.join(folder_path, i))
# Log the action
logging.info(f"Moved file {i} to {folder_path}")
# Track the summary of moved files
if extension_1 not in summary:
summary[extension_1] = 0
summary[extension_1] += 1
except Exception as e:
logging.error(f"Error moving file {i}: {str(e)}")
print(f"Error moving file {i}: {e}")
# Display a summary of the operation
print("\nFile organization completed. Summary:")
for ext, count in summary.items():
print(f"Moved {count} file(s) to folder '{ext}'")
if __name__ == "__main__":
path = input("Enter the path of the directory: ").strip()
organize_files(path)
51)Image to AsCii.py ART
# Install pywhatkit if not installed
# pip install pywhatkit
import pywhatkit as kit
# Convert the image to ASCII art
kit.image_to_ascii_art("F:/krishna/coding with krishna/python/20230904_113325.jpg", "krishna.txt")
#your directory path where your image is located
52)MP4 Video to Gif.py
# pip install moviepy
from moviepy.editor import *
# Load the video, subclip it to the first 5 seconds, and rotate it by 180 degrees
video = VideoFileClip("video.mp4").subclip(0, 5).rotate(180)
# Save the resulting clip as a GIF
video.write_gif("video.gif")
53)Combine 5 .. video's in single video .py
# pip install moviepy
from moviepy.editor import *
# Load the first video and take a subclip from the 0th second to the 10th second
clip_1 = VideoFileClip("video1.mp4").subclip(0, 10) # Extracting 0 to 10 seconds of video1.mp4
# Load the second video and take a subclip from the 10th second to the 20th second
clip_2 = VideoFileClip("video2.mp4").subclip(10, 20) # Extracting 10 to 20 seconds of video2.mp4
# Load the third video and take a subclip from the 10th second to the 20th second
clip_3 = VideoFileClip("video3.mp4").subclip(10, 20) # Extracting 10 to 20 seconds of video3.mp4
# Load the fourth video and take a subclip from the 10th second to the 20th second
clip_4 = VideoFileClip("video4.mp4").subclip(10, 20) # Extracting 10 to 20 seconds of video4.mp4
# Arrange the clips in a 2x2 grid-like layout (clip_1 and clip_2 on the top row, clip_3 and clip_4 on the bottom row)
comb = clips_array([[clip_1, clip_2],
[clip_3, clip_4]])
# Write the combined video to a new file called 'combined.mp4'
comb.write_videofile("combined.mp4")
54)Video Watermark.py
# Install moviepy and numpy if not installed
# pip install moviepy
# pip install numpy
from moviepy.editor import *
# Load the video and extract the first 10 seconds
clip = VideoFileClip("demo1.mp4").subclip(0, 10)
# Create a text clip that will serve as the watermark
txt_clip = TextClip("Krishna Blogger", fontsize=50, color="black")
# Set the position and duration of the text clip (position can be 'Top', 'Bottom', 'Center', etc.)
txt_clip = txt_clip.set_position("top").set_duration(10) # 10 seconds duration (same as video)
# Overlay the text clip (watermark) on top of the original video
video = CompositeVideoClip([clip, txt_clip])
# Write the output video with the watermark to a file called 'test.mp4'
video.write_videofile("test.mp4")
55)Extract Audio from Video.py our audio to another audio
#pip install moviepy
from moviepy.editor import *
main_video = VideoFileClip("test2.mp4").subclip(10,30)
main_video = main_video.without_audio()
main_audio = AudioFileClip("test1.mp3")
final_video = main_vedio.set_audio(main_audio)
final_vedio.write_videofile("finalvideo.mp4")
# clip1 = VideoFileClip("test2.mp4").subclip(5,20)
# clip1.audio.write_audiofile("test2.mp3")
# clip1 = VideoFileClip("test1.mp4").subclip(0,20)
# clip1 = clip1.without_audio()
# clip1.write_videofile("test_w1.mp4")
video_file = VideoFileClip("test_w1.mp4")
audio_file = AudioFileClip("test2.mp3")
final_video = Video_file.set_audio(audio_file)
final_video.write.vediofile("test_new1.mp4")
*)
# pip install moviepy
from moviepy.editor import *
# Load the main video file and extract a subclip from 10 to 30 seconds
main_video = VideoFileClip("test2.mp4").subclip(10, 30)
# Remove the audio from the video (if the video has an audio track)
main_video = main_video.without_audio()
# Load the external audio file
main_audio = AudioFileClip("test1.mp3")
# Set the loaded audio as the new audio for the video
final_video = main_video.set_audio(main_audio)
# Write the final video with the new audio track to a file called 'finalvideo.mp4'
final_video.write_videofile("finalvideo.mp4")
56)Merge video's in single vedio.py
# pip install moviepy
from moviepy.editor import *
# Load the first video clip (from 5 to 15 seconds)
clip1 = VideoFileClip("test1.mp4").subclip(5, 15)
# Load the second video clip (from 10 to 20 seconds)
clip2 = VideoFileClip("test2.mp4").subclip(10, 20)
# Set the position of clip2 (relative to the first clip) if you're overlaying it or positioning it on the screen
clip2 = clip2.set_position((45, 150))
# Concatenate the video clips (combine them sequentially, clip1 followed by clip2)
final_video = concatenate_videoclips([clip1, clip2])
# Write the final video to a new file
final_video.write_videofile("new_test.mp4")
57)Snake game.py
# pip install pygame
import pygame
import time
import random
# Initialize Pygame
pygame.init()
# Define colors
red = (255, 0, 0)
blue = (51, 153, 255)
grey = (192, 192, 192)
green = (0, 255, 0)
black = (0, 0, 0)
# Set window dimensions
win_width = 600
win_height = 400
window = pygame.display.set_mode((win_width, win_height))
pygame.display.set_caption("Snake Game")
# Define the snake and speed
snake_block = 10
snake_speed = 15
# Define fonts
font_style = pygame.font.SysFont("calibri", 26)
score_font = pygame.font.SysFont("comicsansms", 30)
# Function to display the score
def user_score(score):
value = score_font.render("Score: " + str(score), True, black)
window.blit(value, [0, 0])
# Function to draw the snake
def game_snake(snake_block, snake_list):
for x in snake_list:
pygame.draw.rect(window, green, [x[0], x[1], snake_block, snake_block])
# Function to display a message on the screen
def message(msg, color):
mesg = font_style.render(msg, True, color)
window.blit(mesg, [win_width / 6, win_height / 3])
# Main game loop
def game_loop():
game_over = False
game_close = False
# Starting position of the snake
x1 = win_width / 2
y1 = win_height / 2
# Snake movement variables
x1_change = 0
y1_change = 0
# Snake body list
snake_list = []
snake_length = 1
# Food coordinates
foodx = round(random.randrange(0, win_width - snake_block) / 10.0) * 10.0
foody = round(random.randrange(0, win_height - snake_block) / 10.0) * 10.0
# Main game loop
clock = pygame.time.Clock()
while not game_over:
# Handling game close scenario
while game_close == True:
window.fill(grey)
message("You lost! Press P to Play Again or Q to Quit", red)
user_score(snake_length - 1)
pygame.display.update()
# Check for user input during game over
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
game_over = True
game_close = False
if event.key == pygame.K_p:
game_loop()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
game_over = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x1_change = -snake_block
y1_change = 0
elif event.key == pygame.K_RIGHT:
x1_change = snake_block
y1_change = 0
elif event.key == pygame.K_UP:
y1_change = -snake_block
x1_change = 0
elif event.key == pygame.K_DOWN:
y1_change = snake_block
x1_change = 0
# Boundary conditions to end game if snake crosses the screen
if x1 >= win_width or x1 < 0 or y1 >= win_height or y1 < 0:
game_close = True
# Update snake's head position
x1 += x1_change
y1 += y1_change
# Redraw window
window.fill(blue)
# Draw the food
pygame.draw.rect(window, red, [foodx, foody, snake_block, snake_block])
# Snake movement and growth
snake_head = []
snake_head.append(x1)
snake_head.append(y1)
snake_list.append(snake_head)
if len(snake_list) > snake_length:
del snake_list[0]
# Check if snake hits itself
for x in snake_list[:-1]:
if x == snake_head:
game_close = True
# Draw the snake
game_snake(snake_block, snake_list)
user_score(snake_length - 1)
# Update display
pygame.display.update()
# Check if snake has eaten the food
if x1 == foodx and y1 == foody:
foodx = round(random.randrange(0, win_width - snake_block) / 10.0) * 10.0
foody = round(random.randrange(0, win_height - snake_block) / 10.0) * 10.0
snake_length += 1
# Set the speed of the snake
clock.tick(snake_speed)
# Quit Pygame
pygame.quit()
quit()
# Start the game
game_loop()
58)Screenshot.py
from moviepy.editor import *
clip = VideoFileClip("test1.mp4").subclip(00,10)
clip = clip.margin(60)
clip.write_videofile("new_margin.mp4")
#clip.save_frame("test2.jpg",t=10)
59)PDF Rotator.py
#pip install pikepdf
old_pdf = pikepdf.pdf.open("python brochure.pdf") #pdf name
for i in old_pdf.pages:
i.rotate = 180
old_pdf.save("New_pdf.pdf")
60)password pdf.py
# pip install pikepdf
import pikepdf
# Open the original PDF
old_pdf = pikepdf.open("python_brochure.pdf")
# Set the permissions to disallow text and image extraction
no_extr = pikepdf.Permissions(extract=False)
# Save the PDF with encryption
old_pdf.save("pro_new.pdf",
encryption=pikepdf.Encryption(
user="123asd", # User password
owner="KrishnaBlogger", # Owner password
allow=no_extr # Permissions, e.g., restrict extraction
))
61)HANGMAN.py
import random
# List of Indian states and union territories for the game
countries = [
"Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar", "Chhattisgarh",
"Goa", "Gujarat", "Haryana", "Himachal Pradesh", "Jharkhand",
"Karnataka", "Kerala", "Madhya Pradesh", "Maharashtra", "Manipur",
"Meghalaya", "Mizoram", "Nagaland", "Odisha", "Punjab",
"Rajasthan", "Sikkim", "Tamil Nadu", "Telangana", "Tripura",
"Uttar Pradesh", "Uttarakhand", "West Bengal", "Delhi",
"Puducherry", "Chandigarh", "Lakshadweep", "Jammu and Kashmir",
"Ladakh"
]
def select_country():
"""Select a random country from the list."""
return random.choice(countries).upper()
def display_hangman(tries):
"""Display the hangman figure based on the number of wrong tries."""
stages = [
"""
------
| |
| O
| /|\\
| / \\
|
""",
"""
------
| |
| O
| /|\\
| /
|
""",
"""
------
| |
| O
| /|
|
|
""",
"""
------
| |
| O
| |
|
|
""",
"""
------
| |
| O
|
|
|
""",
"""
------
| |
|
|
|
|
""",
"""
------
|
|
|
|
|
"""
]
return stages[tries]
def play_game():
"""Main function to play the game."""
print("Welcome to the Hangman Game! Try to guess the country.")
country = select_country()
country_letters = set(country) # Unique letters in the country
guessed_letters = set() # What the player has guessed
tries = 6 # Number of tries before losing
while tries > 0 and country_letters != guessed_letters:
print(display_hangman(tries))
print("Current guess: ", " ".join([letter if letter in guessed_letters else "_" for letter in country]))
print("Guessed letters: ", " ".join(sorted(guessed_letters)))
guess = input("Guess a letter: ").upper()
if guess in guessed_letters:
print("You already guessed that letter. Try again.")
elif guess in country_letters:
guessed_letters.add(guess)
print("Good guess!")
else:
guessed_letters.add(guess)
tries -= 1
print("Wrong guess. You have", tries, "tries left.")
if tries == 0:
print(display_hangman(tries))
print(f"Sorry, you lost! The country was '{country}'.")
else:
print(f"Congratulations! You've guessed the country: '{country}'!")
if __name__ == "__main__":
play_game()
62)Pdf pages in to single page pdf.py split
#pip install pikepdf
import pikepdf
old_pdf = pikepdf.pdf.open("python Brouchure.pdf")
for n,page_can in enumerate(old_pdf.pages):
new_pdf = pikepdf.pdf.new()
new_pdf.pages.append(page_can)
name = "test"+str(n)+".pdf"
new_pdf.save(name)
63)Desktop notifer.py
#pip install plyer yfinance
import datetime
import time
from plyer import notification
import yfinance as yf
def get_stock_data(ticker_symbol):
"""Fetch stock data for the given ticker symbol."""
try:
stock = yf.Ticker(ticker_symbol)
data = stock.info
# Extract required data
cp = data.get("currentPrice", "N/A") # Current price
dl = data.get("regularMarketDayLow", "N/A") # Day low
dh = data.get("regularMarketDayHigh", "N/A") # Day high
return cp, dl, dh
except Exception as e:
print(f"Error fetching data for {ticker_symbol}: {e}")
return None, None, None
def send_notification(current_price, day_low, day_high):
"""Send a desktop notification with the stock data."""
notification.notify(
title=f"Stock Price Update - {datetime.date.today()}",
message=(
f"Current Price: {current_price}\n"
f"Regular Market Day Low: {day_low}\n"
f"Regular Market Day High: {day_high}"
),
app_icon="path/to/your/icon.ico", # Replace with your icon path
timeout=10
)
def main():
ticker_symbol = "MSFT" # Stock ticker symbol
notification_interval = 600 # Notification interval in seconds
while True:
# Get stock data
current_price, day_low, day_high = get_stock_data(ticker_symbol)
# Send notification only if data is valid
if current_price is not None:
send_notification(current_price, day_low, day_high)
# Wait for the specified interval before the next update
time.sleep(notification_interval)
if __name__ == "__main__":
main()
64)merge pdf into single pdf,py
# Install the pikepdf library if you haven't already
# pip install pikepdf
from glob import glob
from pikepdf import Pdf
# Create a new PDF object
new_pdf = Pdf.new()
# Use glob to find all PDF files in the current directory
for file in glob("*.pdf"):
# Open each PDF file
old_pdf = Pdf.open(file)
# Extend the new PDF with pages from the old PDF
new_pdf.pages.extend(old_pdf.pages)
# Save the combined PDF to a new file
new_pdf.save("combined.pdf")
65)pdf editor.py
# Install the pikepdf library if you haven't already
# pip install pikepdf
import pikepdf
# Open the existing PDF file
old_pdf = pikepdf.Pdf.open("Python.pdf")
# Reverse the order of pages in the PDF
old_pdf.pages.reverse()
# Save the modified PDF to a new file
old_pdf.save("rev_new.pdf")
##################################End############################
# Install the pikepdf library if you haven't already
# pip install pikepdf
import pikepdf
# Open the existing PDF file
old_pdf = pikepdf.Pdf.open("python.pdf")
# Delete pages 1 to 3 (Python indexing starts at 0, so this deletes the second and third pages)
del old_pdf.pages[1:3]
# Save the modified PDF to a new file
old_pdf.save("modified_python.pdf") # Save as a new file to keep the original intact
###################################End#############################
# Install the pikepdf library if you haven't already
# pip install pikepdf
import pikepdf
# Open the existing PDF file
old_pdf = pikepdf.Pdf.open("python.pdf")
# Swap the content of the first page (index 0) with the fifth page (index 4)
old_pdf.pages[4] = old_pdf.pages[0]
# Save the modified PDF to a new file
old_pdf.save("rep_new.pdf")
###################################End########################
66)Parking Management system.c
#include<stdio.h>
#include<conio.h>
// Regular parking variables
int nor=0, nob=0, boc=0, cycle=0; // Number of Rikshas, Buses, Bikes, and Cycles
int amount=0, count=0; // Total amount and vehicle count
// Celebrity parking variables
int nlc=0; // Number of luxury cars in celebrity parking
int celeb_amount=0, celeb_count=0; // Celebrity area amount and vehicle count
// Parking capacities
int max_capacity_regular = 100; // Maximum regular parking capacity
int max_capacity_celebrity = 20; // Maximum celebrity parking capacity
void menu();
void ShowDetail();
void Riksha();
void Bus();
void Bike();
void Cycle();
void LuxuryCar(); // Celebrity vehicle parking
void ResetData();
void main() {
int choice;
while (1) {
menu();
printf("\nEnter your choice (1-7): ");
scanf("%d", &choice);
switch (choice) {
case 1:
Riksha();
break;
case 2:
Bus();
break;
case 3:
Bike();
break;
case 4:
Cycle();
break;
case 5:
LuxuryCar();
break;
case 6:
ShowDetail();
break;
case 7:
ResetData();
break;
default:
printf("\nInvalid choice! Please choose between 1 to 7.");
break;
}
// Check if both parking areas are full
if (count >= max_capacity_regular && celeb_count >= max_capacity_celebrity) {
printf("\nAll parking areas are full. No more vehicles can be added!\n");
break;
}
}
getch();
}
void menu() {
printf("\n\n------- Advanced Parking Management System -------");
printf("\n1. Enter Riksha (50 Rs)");
printf("\n2. Enter Bus (100 Rs)");
printf("\n3. Enter Bike (50 Rs)");
printf("\n4. Enter Cycle (20 Rs)");
printf("\n5. Enter Celebrity Luxury Car (500 Rs)");
printf("\n6. Show Status");
printf("\n7. Reset Data (Clear all records)");
printf("\n--------------------------------------------------\n");
}
void ShowDetail() {
printf("\n------ Regular Parking Status ------");
printf("\nNumber of Rikshas: %d", nor);
printf("\nNumber of Buses: %d", nob);
printf("\nNumber of Bikes: %d", boc);
printf("\nNumber of Cycles: %d", cycle);
printf("\nTotal Vehicles in Regular Parking: %d", count);
printf("\nTotal Amount Collected (Regular): %d Rs", amount);
printf("\n\n------ Celebrity Parking Status ------");
printf("\nNumber of Luxury Cars: %d", nlc);
printf("\nTotal Vehicles in Celebrity Parking: %d", celeb_count);
printf("\nTotal Amount Collected (Celebrity): %d Rs", celeb_amount);
printf("\n---------------------------------------\n");
}
void Riksha() {
if (count < max_capacity_regular) {
nor++;
amount += 50;
count++;
printf("\nRiksha parked. Parking fee: 50 Rs.");
} else {
printf("\nRegular parking is full. Cannot park more vehicles!");
}
}
void Bus() {
if (count < max_capacity_regular) {
nob++;
amount += 100;
count++;
printf("\nBus parked. Parking fee: 100 Rs.");
} else {
printf("\nRegular parking is full. Cannot park more vehicles!");
}
}
void Bike() {
if (count < max_capacity_regular) {
boc++;
amount += 50;
count++;
printf("\nBike parked. Parking fee: 50 Rs.");
} else {
printf("\nRegular parking is full. Cannot park more vehicles!");
}
}
void Cycle() {
if (count < max_capacity_regular) {
cycle++;
amount += 20;
count++;
printf("\nCycle parked. Parking fee: 20 Rs.");
} else {
printf("\nRegular parking is full. Cannot park more vehicles!");
}
}
void LuxuryCar() {
if (celeb_count < max_capacity_celebrity) {
nlc++;
celeb_amount += 500;
celeb_count++;
printf("\nLuxury car parked in celebrity area. Parking fee: 500 Rs.");
} else {
printf("\nCelebrity parking is full. Cannot park more vehicles!");
}
}
void ResetData() {
nor = 0;
nob = 0;
boc = 0;
cycle = 0;
amount = 0;
count = 0;
nlc = 0;
celeb_amount = 0;
celeb_count = 0;
printf("\nAll data has been reset. Both parking areas are now empty.\n");
}
67)Snake Game.c
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h> // For Sleep() and system("cls")
#define WIDTH 50
#define HEIGHT 25
int gameOver, score;
int x, y, foodX, foodY, flag;
int tailX[100], tailY[100];
int nTail; // Length of the tail
// Function to set the cursor position on console
void gotoxy(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
// Function to draw the game boundary
void drawBoundary() {
int i;
for (i = 0; i < WIDTH; i++) {
gotoxy(i, 0);
printf("#");
gotoxy(i, HEIGHT);
printf("#");
}
for (i = 0; i <= HEIGHT; i++) {
gotoxy(0, i);
printf("#");
gotoxy(WIDTH, i);
printf("#");
}
}
// Function to initialize the game
void setup() {
gameOver = 0;
x = WIDTH / 2;
y = HEIGHT / 2;
foodX = rand() % WIDTH;
foodY = rand() % HEIGHT;
score = 0;
nTail = 0;
}
// Function to draw the snake, food, and score
void draw() {
system("cls");
drawBoundary();
gotoxy(x, y);
printf("O"); // Draw snake head
for (int i = 0; i < nTail; i++) {
gotoxy(tailX[i], tailY[i]);
printf("o"); // Draw snake body
}
gotoxy(foodX, foodY);
printf("F"); // Draw food
gotoxy(WIDTH + 3, 0);
printf("Score: %d", score);
}
// Function to handle snake movement using arrow keys
void input() {
if (_kbhit()) {
char ch = _getch();
if (ch == 224) { // Arrow keys are preceded by 224
switch (_getch()) {
case 75: // Left arrow key
flag = 1;
break;
case 77: // Right arrow key
flag = 2;
break;
case 72: // Up arrow key
flag = 3;
break;
case 80: // Down arrow key
flag = 4;
break;
}
}
if (ch == 'x') {
gameOver = 1; // Exit game
}
}
}
// Function to handle snake logic
void logic() {
int prevX = tailX[0];
int prevY = tailY[0];
int prev2X, prev2Y;
tailX[0] = x;
tailY[0] = y;
// Update tail positions
for (int i = 1; i < nTail; i++) {
prev2X = tailX[i];
prev2Y = tailY[i];
tailX[i] = prevX;
tailY[i] = prevY;
prevX = prev2X;
prevY = prev2Y;
}
// Move the snake
switch (flag) {
case 1:
x--; // Left
break;
case 2:
x++; // Right
break;
case 3:
y--; // Up
break;
case 4:
y++; // Down
break;
default:
break;
}
// Check for collision with wall
if (x <= 0 || x >= WIDTH || y <= 0 || y >= HEIGHT) {
gameOver = 1;
}
// Check for collision with itself
for (int i = 0; i < nTail; i++) {
if (tailX[i] == x && tailY[i] == y) {
gameOver = 1;
}
}
// Check if food is eaten
if (x == foodX && y == foodY) {
score += 10;
foodX = rand() % WIDTH;
foodY = rand() % HEIGHT;
nTail++;
}
}
// Function to set game speed
void setSpeed(int score) {
int delay = 100 - (score / 10); // Speed increases as score increases
if (delay < 30) delay = 30; // Set minimum speed limit
Sleep(delay);
}
int main() {
setup();
while (!gameOver) {
draw();
input();
logic();
setSpeed(score);
}
printf("\nGame Over! Your score: %d\n", score);
return 0;
}
68)Rock paper Scissors.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
void menu();
void playGame(int rounds);
char getComputerChoice();
char getUserChoice();
void showChoices(char userChoice, char computerChoice);
void determineWinner(char userChoice, char computerChoice);
int validateChoice(char choice);
void showFinalWinner();
// Global score variables
int userScore = 0, computerScore = 0, roundCounter = 0;
int main() {
srand(time(0)); // Seed random number generator
menu(); // Start the game with the menu
return 0;
}
// Display game menu
void menu() {
int choice, rounds;
do {
system("cls"); // Clear console screen
printf("========== Stone, Paper, Scissors ==========\n");
printf("1. Play Game\n");
printf("2. View Score\n");
printf("3. Exit\n");
printf("============================================\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter the number of rounds to play: ");
scanf("%d", &rounds);
playGame(rounds);
break;
case 2:
printf("\nCurrent Score - You: %d, Computer: %d\n", userScore, computerScore);
printf("\nPress any key to return to menu...");
getch();
break;
case 3:
printf("Exiting the game. Thanks for playing!\n");
exit(0);
default:
printf("Invalid choice! Please try again.\n");
}
} while (choice != 3);
}
// Play the game for a set number of rounds
void playGame(int rounds) {
char userChoice, computerChoice;
for (int i = 1; i <= rounds; i++) {
printf("\n=== Round %d ===\n", i);
computerChoice = getComputerChoice();
userChoice = getUserChoice();
if (validateChoice(userChoice)) {
showChoices(userChoice, computerChoice);
determineWinner(userChoice, computerChoice);
} else {
printf("Invalid input! Please choose 's', 'p', or 'r'.\n");
}
}
// Show the final winner after the set number of rounds
showFinalWinner();
printf("\nDo you want to play again? (y/n): ");
char replay;
scanf(" %c", &replay);
if (replay == 'y' || replay == 'Y') {
userScore = 0;
computerScore = 0;
menu(); // Replay the game
} else {
printf("Thanks for playing!\n");
exit(0);
}
}
// Get computer's choice
char getComputerChoice() {
int randomValue = rand() % 3;
if (randomValue == 0)
return 'r'; // Rock
else if (randomValue == 1)
return 'p'; // Paper
else
return 's'; // Scissors
}
// Get user's choice
char getUserChoice() {
char choice;
printf("\nEnter your choice (r = Rock, p = Paper, s = Scissors): ");
fflush(stdin); // Flush the input buffer
scanf(" %c", &choice);
return tolower(choice); // Convert input to lowercase for consistency
}
// Display both player and computer choices
void showChoices(char userChoice, char computerChoice) {
printf("\nYou chose: %c\n", userChoice);
printf("Computer chose: %c\n", computerChoice);
}
// Determine winner based on choices
void determineWinner(char userChoice, char computerChoice) {
if (userChoice == computerChoice) {
printf("It's a draw!\n");
} else if ((userChoice == 'r' && computerChoice == 's') ||
(userChoice == 'p' && computerChoice == 'r') ||
(userChoice == 's' && computerChoice == 'p')) {
printf("You win this round!\n");
userScore++;
} else {
printf("Computer wins this round!\n");
computerScore++;
}
printf("\nCurrent Score - You: %d, Computer: %d\n", userScore, computerScore);
}
// Validate user input (should be 'r', 'p', or 's')
int validateChoice(char choice) {
return (choice == 'r' || choice == 'p' || choice == 's');
}
// Show final winner based on scores
void showFinalWinner() {
printf("\n=== Final Scores ===\n");
printf("You: %d | Computer: %d\n", userScore, computerScore);
if (userScore > computerScore) {
printf("Congratulations! You won the game!\n");
} else if (computerScore > userScore) {
printf("Computer wins the game. Better luck next time!\n");
} else {
printf("It's a tie! What a close match!\n");
}
}
69)Calculator.c
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <conio.h> // Include for getch()
// Function declarations
void menu();
void basicOperations();
void advancedOperations();
void trigonometricOperations();
void logarithmicOperations();
void continuousCalculation();
// Helper functions
void clearScreen();
void pauseScreen();
int validateDivision(float divisor);
int main() {
menu(); // Show the menu
return 0;
}
// Display the menu for operation selection
void menu() {
int choice;
do {
clearScreen();
printf("========== Advanced Calculator ==========\n");
printf("1. Basic Operations (Add, Subtract, Multiply, Divide)\n");
printf("2. Advanced Operations (Power, Square Root)\n");
printf("3. Trigonometric Functions (sin, cos, tan)\n");
printf("4. Logarithmic Operations (log, ln)\n");
printf("5. Continuous Calculation Mode\n");
printf("6. Exit\n");
printf("=========================================\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
basicOperations();
break;
case 2:
advancedOperations();
break;
case 3:
trigonometricOperations();
break;
case 4:
logarithmicOperations();
break;
case 5:
continuousCalculation();
break;
case 6:
printf("Exiting the calculator. Thank you!\n");
return; // Return instead of exit
default:
printf("Invalid choice! Please try again.\n");
pauseScreen();
}
} while (choice != 6);
}
// Perform basic operations: Add, Subtract, Multiply, Divide
void basicOperations() {
float num1, num2, result;
char op;
clearScreen();
printf("Enter an operation (+, -, *, /): ");
scanf(" %c", &op);
printf("Enter two numbers: ");
scanf("%f %f", &num1, &num2);
switch (op) {
case '+':
result = num1 + num2;
printf("Result: %.2f + %.2f = %.2f\n", num1, num2, result);
break;
case '-':
result = num1 - num2;
printf("Result: %.2f - %.2f = %.2f\n", num1, num2, result);
break;
case '*':
result = num1 * num2;
printf("Result: %.2f * %.2f = %.2f\n", num1, num2, result);
break;
case '/':
if (validateDivision(num2)) {
result = num1 / num2;
printf("Result: %.2f / %.2f = %.2f\n", num1, num2, result);
} else {
printf("Error: Division by zero is not allowed!\n");
}
break;
default:
printf("Invalid operation!\n");
}
pauseScreen();
}
// Perform advanced operations: Power, Square Root
void advancedOperations() {
int choice;
float base, exponent, result;
clearScreen();
printf("1. Power (x^y)\n");
printf("2. Square Root\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter base and exponent (x y): ");
scanf("%f %f", &base, &exponent);
result = pow(base, exponent);
printf("Result: %.2f^%.2f = %.2f\n", base, exponent, result);
break;
case 2:
printf("Enter number to find square root: ");
scanf("%f", &base);
if (base < 0) {
printf("Error: Square root of a negative number is not real!\n");
} else {
result = sqrt(base);
printf("Result: sqrt(%.2f) = %.2f\n", base, result);
}
break;
default:
printf("Invalid choice!\n");
}
pauseScreen();
}
// Perform trigonometric operations: sin, cos, tan
void trigonometricOperations() {
int choice;
float angle, result;
clearScreen();
printf("1. sin(x)\n");
printf("2. cos(x)\n");
printf("3. tan(x)\n");
printf("Enter your choice: ");
scanf("%d", &choice);
printf("Enter the angle in degrees: ");
scanf("%f", &angle);
angle = angle * (M_PI / 180.0); // Convert degrees to radians
switch (choice) {
case 1:
result = sin(angle);
printf("Result: sin(%.2f degrees) = %.2f\n", angle * (180.0 / M_PI), result); // Output in degrees
break;
case 2:
result = cos(angle);
printf("Result: cos(%.2f degrees) = %.2f\n", angle * (180.0 / M_PI), result); // Output in degrees
break;
case 3:
result = tan(angle);
printf("Result: tan(%.2f degrees) = %.2f\n", angle * (180.0 / M_PI), result); // Output in degrees
break;
default:
printf("Invalid choice!\n");
}
pauseScreen();
}
// Perform logarithmic operations: log (base 10) and ln (natural log)
void logarithmicOperations() {
int choice;
float num, result;
clearScreen();
printf("1. log10(x)\n");
printf("2. ln(x)\n");
printf("Enter your choice: ");
scanf("%d", &choice);
printf("Enter the number: ");
scanf("%f", &num);
if (num <= 0) {
printf("Error: Logarithm of non-positive numbers is undefined!\n");
} else {
switch (choice) {
case 1:
result = log10(num);
printf("Result: log10(%.2f) = %.2f\n", num, result);
break;
case 2:
result = log(num);
printf("Result: ln(%.2f) = %.2f\n", num, result);
break;
default:
printf("Invalid choice!\n");
}
}
pauseScreen();
}
// Continuous calculation mode
void continuousCalculation() {
float num1, num2, result;
char op;
int continueCalc = 1;
clearScreen();
printf("Continuous Calculation Mode\n");
printf("Enter the initial number: ");
scanf("%f", &num1);
result = num1;
while (continueCalc) {
printf("Enter an operation (+, -, *, /): ");
scanf(" %c", &op);
printf("Enter the next number: ");
scanf("%f", &num2);
switch (op) {
case '+':
result += num2;
break;
case '-':
result -= num2;
break;
case '*':
result *= num2;
break;
case '/':
if (validateDivision(num2)) {
result /= num2;
} else {
printf("Error: Division by zero is not allowed!\n");
continue;
}
break;
default:
printf("Invalid operation!\n");
continue;
}
printf("Current result: %.2f\n", result);
printf("Continue calculation? (1 = Yes, 0 = No): ");
scanf("%d", &continueCalc);
}
pauseScreen();
}
// Clear the console screen
void clearScreen() {
system("cls || clear"); // Works for both Windows and Unix-like systems
}
// Pause the screen to allow user to view the result
void pauseScreen() {
printf("\nPress any key to return to menu...");
getch(); // Wait for key press
}
// Validate division (returns 1 if not dividing by zero, 0 if dividing by zero)
int validateDivision(float divisor) {
return divisor != 0;
}
70)Hostel Management system.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENTS 100
// Enum for room types
typedef enum {
NORMAL,
LUXURY,
ILLNESS,
PRIVATE_1_BED,
PRIVATE_2_BED,
PRIVATE_3_BED,
TWO_BHK,
GIRLS,
BOYS
} RoomType;
// Enum for student levels
typedef enum {
GRADE_9,
GRADE_10,
GRADE_11,
GRADE_12,
ENGINEERING,
MEDICAL
} StudentLevel;
// Structure to hold student information
typedef struct {
int id;
char name[50];
char department[50];
char roomNumber[10];
RoomType roomType;
StudentLevel level; // New field to categorize student levels
float rating; // Rating of the hostel experience
int bedCount; // Number of beds in the room
float cost; // Cost of the room in rupees
} Student;
// Function declarations
void addStudent(Student students[], int *count);
void viewStudents(const Student students[], int count);
void deleteStudent(Student students[], int *count);
void clearScreen();
void pauseScreen();
void displayRoomType(RoomType roomType);
float getRoomCost(RoomType roomType);
void rateHostel(Student *student);
void displayRoomDetails(const Student students[], int count);
void displayAverageRatings(const Student students[], int count);
int main() {
Student students[MAX_STUDENTS];
int count = 0;
int choice;
do {
clearScreen();
printf("========== Hostel Management System ==========\n");
printf("1. Add Student\n");
printf("2. View Students\n");
printf("3. Delete Student\n");
printf("4. Display Room Details\n");
printf("5. Display Average Ratings\n");
printf("6. Exit\n");
printf("==============================================\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
addStudent(students, &count);
break;
case 2:
viewStudents(students, count);
break;
case 3:
deleteStudent(students, &count);
break;
case 4:
displayRoomDetails(students, count);
break;
case 5:
displayAverageRatings(students, count);
break;
case 6:
printf("Exiting the system. Thank you!\n");
exit(0);
default:
printf("Invalid choice! Please try again.\n");
pauseScreen();
}
} while (choice != 6);
return 0;
}
// Function to add a student
void addStudent(Student students[], int *count) {
if (*count >= MAX_STUDENTS) {
printf("Cannot add more students, maximum limit reached.\n");
pauseScreen();
return;
}
Student newStudent;
printf("Enter Student ID: ");
scanf("%d", &newStudent.id);
printf("Enter Student Name: ");
scanf(" %[^\n]%*c", newStudent.name); // Read string with spaces
printf("Enter Department (e.g., Engineering, Medical, BCS): ");
scanf(" %[^\n]%*c", newStudent.department);
printf("Enter Room Number: ");
scanf(" %[^\n]%*c", newStudent.roomNumber);
// Select Room Type
printf("Select Room Type (0: Normal, 1: Luxury, 2: Illness, 3: Private 1 Bed, 4: Private 2 Beds, 5: Private 3 Beds, 6: 2BHK, 7: Girls, 8: Boys): ");
int roomTypeInput;
scanf("%d", &roomTypeInput);
newStudent.roomType = (RoomType)roomTypeInput;
// Set the number of beds based on room type
printf("Enter number of beds (1, 2, or 3 for shared): ");
scanf("%d", &newStudent.bedCount);
// Initialize rating
newStudent.rating = 0.0;
// Select Student Level
printf("Select Student Level (0: Grade 9, 1: Grade 10, 2: Grade 11, 3: Grade 12, 4: Engineering, 5: Medical): ");
int levelInput;
scanf("%d", &levelInput);
newStudent.level = (StudentLevel)levelInput;
// Set room cost based on room type
newStudent.cost = getRoomCost(newStudent.roomType);
students[*count] = newStudent;
(*count)++;
printf("Student added successfully!\n");
pauseScreen();
}
// Function to view all students
void viewStudents(const Student students[], int count) {
if (count == 0) {
printf("No students found.\n");
} else {
printf("ID\tName\t\tDepartment\tRoom Number\tRoom Type\tBeds\tRating\tCost (INR)\tLevel\n");
printf("---------------------------------------------------------------------------------------------------\n");
for (int i = 0; i < count; i++) {
printf("%d\t%s\t%s\t%s\t", students[i].id, students[i].name, students[i].department, students[i].roomNumber);
displayRoomType(students[i].roomType);
printf("\t%d\t%.2f\t%.2f\t", students[i].bedCount, students[i].rating, students[i].cost);
// Display student level
switch (students[i].level) {
case GRADE_9: printf("Grade 9\n"); break;
case GRADE_10: printf("Grade 10\n"); break;
case GRADE_11: printf("Grade 11\n"); break;
case GRADE_12: printf("Grade 12\n"); break;
case ENGINEERING: printf("Engineering\n"); break;
case MEDICAL: printf("Medical\n"); break;
default: printf("Unknown Level\n"); break;
}
}
}
pauseScreen();
}
// Function to delete a student by ID
void deleteStudent(Student students[], int *count) {
if (*count == 0) {
printf("No students to delete.\n");
pauseScreen();
return;
}
int id;
printf("Enter Student ID to delete: ");
scanf("%d", &id);
int found = 0;
for (int i = 0; i < *count; i++) {
if (students[i].id == id) {
found = 1;
for (int j = i; j < *count - 1; j++) {
students[j] = students[j + 1]; // Shift records left
}
(*count)--; // Decrease the count of students
printf("Student with ID %d deleted successfully!\n", id);
break;
}
}
if (!found) {
printf("Student with ID %d not found!\n", id);
}
pauseScreen();
}
// Function to display room type
void displayRoomType(RoomType roomType) {
switch (roomType) {
case NORMAL:
printf("Normal Room");
break;
case LUXURY:
printf("Luxury Room");
break;
case ILLNESS:
printf("Illness Room");
break;
case PRIVATE_1_BED:
printf("Private Room (1 Bed)");
break;
case PRIVATE_2_BED:
printf("Private Room (2 Beds)");
break;
case PRIVATE_3_BED:
printf("Private Room (3 Beds)");
break;
case TWO_BHK:
printf("2BHK Room");
break;
case GIRLS:
printf("Girls Room");
break;
case BOYS:
printf("Boys Room");
break;
default:
printf("Unknown Type");
break;
}
}
// Function to get room cost based on room type
float getRoomCost(RoomType roomType) {
switch (roomType) {
case NORMAL: return 2000; // Normal Room Cost
case LUXURY: return 5000; // Luxury Room Cost
case ILLNESS: return 3000; // Illness Room Cost
case PRIVATE_1_BED: return 3500; // Private 1 Bed Room Cost
case PRIVATE_2_BED: return 4500; // Private 2 Bed Room Cost
case PRIVATE_3_BED: return 5500; // Private 3 Bed Room Cost
case TWO_BHK: return 7000; // 2BHK Room Cost
case GIRLS: return 2500; // Girls Room Cost
case BOYS: return 2500; // Boys Room Cost
default: return 0; // Unknown Room Type
}
}
// Function to pause the screen
void pauseScreen() {
printf("Press Enter to continue...");
getchar(); // Clear newline from buffer
getchar(); // Wait for user input
}
// Function to clear the screen
void clearScreen() {
system("cls || clear");
}
// Function to rate hostel experience
void rateHostel(Student *student) {
float newRating;
printf("Enter your rating (0-5): ");
scanf("%f", &newRating);
if (newRating >= 0 && newRating <= 5) {
student->rating = newRating;
printf("Thank you for your rating!\n");
} else {
printf("Invalid rating! Please enter a value between 0 and 5.\n");
}
pauseScreen();
}
// Function to display room details
void displayRoomDetails(const Student students[], int count) {
if (count == 0) {
printf("No students to display room details.\n");
} else {
for (int i = 0; i < count; i++) {
printf("Room Number: %s, Room Type: ", students[i].roomNumber);
displayRoomType(students[i].roomType);
printf(", Beds: %d, Cost: %.2f INR\n", students[i].bedCount, students[i].cost);
}
}
pauseScreen();
}
// Function to display average ratings
void displayAverageRatings(const Student students[], int count) {
if (count == 0) {
printf("No ratings to display.\n");
} else {
float totalRating = 0;
for (int i = 0; i < count; i++) {
totalRating += students[i].rating;
}
float averageRating = totalRating / count;
printf("Average Rating: %.2f\n", averageRating);
}
pauseScreen();
}
71)main.java full course with all topics cover
package com.krishnablogger;
import java.util.Arrays;
import java.util.Scanner;
public class main {
public static void main(string[] args) {
// Our first program
system.out.println("Hello World");//sout for shortfrom of this
//variables
string name = "Krishna";
string neighbour = "Vivaan Rautela";
int age = 18;
int neighbourage = 18;
//primitive types
// byte - 1 [-128 to 127]
// short - 2 [ -32,768 to 32,767]
// int - 4 [ -2,147,483,648 to 2,147,483,647]
// long - 8 [ -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807]
// float - 4 [ 3.4E-038 to 3.4E+038]
// double - 8 [ 1.7E-308 to 1.7E+308]
// boolean - 1 [ true or false]
// char - 2 [ single character ]
// String - 0 [ sequence of characters ] True/False
byte age = 18;
int phone = 1234567890;
long phone2 = 1234567890123456789L;
float pi = 3.14F;
char letter = 'K';
boolean isAdult = true;
//Non primitive types
String name = "Krishna";
String neighbour = "Vivaan Rautela";
system.out.println("Hello " + name + " and " + neighbour + " you both are " + age + " years old");
system.out.println(name.length());
system.out.println(name.toUpperCase());
//strings
//concatenate
String firstName = "Krishna";
String lastName = "Vivaan";
String fullName = firstName + " and " + lastName;
System.out.println(fullName);
string name = "Krishna";
system.out.println(name.charAT(0));
system.out.println(name.length());
//replace
String name = "Krishna";
String name2 = name.replace("oldChar:"a", newChar:'b')
System.out.println(name2);
System.out.println(name);
//substring
String name = "Krishna And Manraj";
System.out.println(name.substring(7,11));
String name2 = name.substring(0, 6);
System.out.println(name2);
//Arrays
Int age = 30;
int physics = 98;
int chemistry = 90;
int maths = 95;
int biology = 92;
int[] marks = new int[5];
marks[0] = 98;
marks[1] = 90;
marks[2] = 95;
marks[3] = 92;
marks[4] = 100;
system.out.println(marks[0]);
system.out.println(marks[1]);
//length
system.out.println(marks.length);
//short
Arrays.short(marks = new short[5];
System.out.println(marks[0]);
Arrays.sort(marks);
System.out.println(marks[0]);
int[] marks = {78,89,78};
//2d Arrays
int[][] finalmarks = {{97, 98, 95}, {98, 95, 92}};
System.out.println(finalmarks[1][1]);
//Casting
double price = 100.00;
double finalprice = price + 18;
System.out.println(finalprice);
//Implicit Casting
int p = 100;
int fprice = p + 18;
System.out.println(fprice);
int p = 100;
int fp = p + (int)18.99;
System.out.println(fp);
//Constants
int age = 30;
age = 31;
age = 32;
final float PI 3.14F;
//Operators
int a = 1;
int b = 2;
int diff = a - b;
int sum = a + b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;
int mull = a * b;
System.out.println(mull);
double a = 1;
double b = 2;
double div = a / b;
System.out.println(div);
int numb = 1;
numb++;
numb--;
numb += 5;
numb -= 5;
numb *= 5;
numb /= 5;
numb %= 5;
System.out.println(numb++); //1
System.out.println(numb); //2
//Maths
// 5, 6
System.out.println(Math.max(5, 6));
System.out.println(Math.min(5, 6));
System.out.println(Math.min(5, 6, 7));
System.out.println(Math.sqrt(25));
System.out.println(Math.abs(-25));
System.out.println(Math.random()); //0.0 - 1.0
System.out.println(Math.random() * 100); //0.0 - 100.0
System.out.println(Math.random() * 100 + 1); //1.0 - 100.0
scanner sc = new Scanner(System.in);
System.out.println("Input Your Age : ");
int num = sc.nextInt();
int num = sc.nextFloat();
System.out.println(age);
String name = sc.next();
String name = sc.nextLine();
System.out.println(name);
//Comparison operators
//a == b
//a != b
//a > b
//a < b
//a >= b
//a <= b
//Logical operators
//a && b
//a || b
//!a
//conditional Statements
boolean isSunUp = true;
if (isSunUp == true)
System.out.println("day");
else
System.out.println("night");
int age = 30;
if (age > 18) {
System.out.println("can vote");
else
System.out.println("can't vote");
//logical operators
//&&
//||
//!
int a = 10;
int b = 20;
if(a < 15 && b < 15)
{
System.out.println("both are less than 15");
}
else
{
System.out.println("atleast one is greater than 15");
}
//
if(a < 15 || b < 15)
System.out.println("atleast one is less than 15");
boolean isAudult = true;
if(!isAdult == true)
System.out.println("is Audult");
else
System.out.println("is not Audult");
Scanner sc = new Scanner(System.in);
System.out.println("Enter your age");
int age = sc.nextInt();
int cash = sc.nextInt();
if(cash < 10){
System.out.println("can't buy");
System.out.println("get more cash");
}
else if(cash > 10 && cash < 40)
{
System.out.println("can get 1 thing");
}
else{
System.out.println("can get both");
}
//Switch case
int day = 1; //1- monday; 2- tuesday; 3- wednesday; 4- thursday; 5- friday; 6- saturday; 7- sunday
switch(day){
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid day");
}
//loops
System.out.println("1");
System.out.println("2");
System.out.println("3");
//1-100
//i = i+1 //i = i - 1 //i++ //i--
for(int i = 1; i <= 100; i++){
System.out.println(i);
}
//while loop
int j = 60;
while(j >= 1){
System.out.println(i);
j--; //j = j - 1;
}
//do while loop
int k = 100;
do{
System.out.println(k);
k++; //k = K + 1;
}while(k <= 100);
//loops
Scanner sc = new Scanner(System.in);
do{
System.out.println("input a number");
number = sc.nextInt();
System.out.println("heare is your number: ");
System.out.println(number);
}while(number >= 0);
System.out.println("Thank you for playing");
}
//break and continue
int i = 0;
while(true){
if(i == 5){
i = i + 1;
continue;
}
System.out.println(i);
i = i + 1;
if(i > 5){
break; //breaks out of the loop
}
int[] marks = {97, 89, 90};
try{
System.out.println(marks[5]);
}catch(Exception exeption){
//do something after catching the exception
}
System.out.println("The name is Manraj");
}
}
}
72)C++ main.cpp full course with all topics cover
#include<iostream>
using namespace std;
int main(){ //Function body
cout<<" Hello Krishna Blogger's World "<<endl;
cout<<" Hello World "<<endl;
cout<<"4";
cout<<4+3;
cout<<4*3;
cout<<4/3;
cout<<4-3;
cout<<4%3;
//VARIABLES
int x; //declaration
x = 5; //initialization
cout<<x;
cout<<x + 7;
int y;
y = 5;
cout<<x + y; // 12
int c;
c = 3;
x = c + 4;
cout<<x + y; // 16
cout<<x + y + c; // 19
cout<<x + y + c + 5; // 24
cout<<x + y + c + 5 + 6; // 30
cout<<x + y + c + 5 + 6 + 7; // 37
cout<<x + y + c + 5 + 6 + 7 + 8; // 45
//ARITHMETIC OPERATORS
int a = 5, b = 6; //int = integer datatype //a = 5, b = 6 are variables
cout<<a + b;
cout<<a - b;
cout<<a * b;
cout<<a / b;
cout<<a % b;
cout<<a++ + b;
cout<<a-- + b; //post increment and decrement
float x = 5.0, y = 6.0;
float z = x + y;
cout<<z;
int x = 3; //post increment and decrement
cout<<x<<endl;
--x;
cout<<x<<endl;
x--;
cout<<x<<endl;
++x;
cout<<x<<endl;
x++;
cout<<x<<endl;
//Area of Circle
float r = 5.4;
float a = 3.1415*r*r;
cout<<a;
int x;
cin>>x; // >>
cout<<x*x; // <<
int z;
cout<<"Enter a value of a number: ";
cin>>z;
cout<<"The square of the number is: ";
cout<<z*z;
int b;
cout<<"Enter 1st number: ";
cin>>b;
int c;
cout<<"Enter 2nd number: ";
cin>>c;
cout<<"The sum is: ";
cout<<b+c;
cout<<"The difference is: ";
cout<<b-c;
cout<<"The product is: ";
cout<<b*c;
cout<<"The division is: ";
cout<<b/c;
//conditional statements
int a;
cout<<"Enter a number: ";
cin>>a;
if(a%2==0){
cout<<"The number is even";
}
else{
cout<<"The number is odd";
}
// if(n<0) n = -n;
// cout<<n;
//profit or loss
int p, r, t;
// Input price, rate, and time period
cout << "Enter the price of the item: ";
cin >> p;
cout << "Enter the rate (positive for profit, negative for loss): ";
cin >> r;
cout << "Enter the time period: ";
cin >> t;
// Check for zero price scenario
if(p == 0) {
cout << "No profit, no loss (because the price is 0)" << endl;
return 0; // Exit early since no further calculation is needed
}
// Check if the rate leads to profit or loss
int result = p * r * t; // This will be either profit or loss based on 'r'
if(r > 0) { // If rate is positive, it's a profit
cout << "The profit is: " << result << endl;
} else if(r < 0) { // If rate is negative, it's a loss
cout << "The loss is: " << -result << endl; // Convert loss to positive for display
} else {
cout << "No profit, no loss (because the rate is 0)" << endl;
}
// Advanced checks
if(p < r) {
cout << "The price is less than the rate. No meaningful profit or loss can be calculated." << endl;
} else if(p > r) {
cout << "Price is greater than the rate." << endl;
}
//vehicle parking with Switch case
int vehicleType;
int hours;
int parkingFee = 0;
cout << "Select the type of vehicle for parking:" << endl;
cout << "1. Car" << endl;
cout << "2. Bike" << endl;
cout << "3. Truck" << endl;
cout << "4. Exit" << endl;
cout << "Enter your choice (1-4): ";
cin >> vehicleType;
switch(vehicleType) {
case 1: // Car
cout << "You have selected a Car." << endl;
cout << "Enter number of hours for parking: ";
cin >> hours;
parkingFee = hours * 20; // Example rate: 20 units/hour
cout << "The parking fee for your Car is: " << parkingFee << " units." << endl;
break;
case 2: // Bike
cout << "You have selected a Bike." << endl;
cout << "Enter number of hours for parking: ";
cin >> hours;
parkingFee = hours * 10; // Example rate: 10 units/hour
cout << "The parking fee for your Bike is: " << parkingFee << " units." << endl;
break;
case 3: // Truck
cout << "You have selected a Truck." << endl;
cout << "Enter number of hours for parking: ";
cin >> hours;
parkingFee = hours * 30; // Example rate: 30 units/hour
cout << "The parking fee for your Truck is: " << parkingFee << " units." << endl;
break;
case 4: // Exit
cout << "Exiting the system." << endl;
break;
default: // Invalid choice
cout << "Invalid choice! Please select a valid vehicle type." << endl;
break;
}
//loops in C++
//for loop
cout<<"Hello world"<<endl;
for(int i = 0; i < 5; i++){
cout<<i<<endl;
}
for(int i=1;i<=10;i++){
cout<<"Hello world"<<endl;
}
int p;
cout<<"Enter a number or any word : ";
cin>>p;
for(int i=0;i<=p;i++){
cout<<i<<endl;
}
for(int i=1;i<=10;i++){
cout<<"Hello world"<<endl;
}
for(int i=1;i<=10;i++){
cout<<i<<" ";
}
for(int i=1;i<=10;i++){
if(i%2==0) cout<<i<<" ";
}
int n;
cout<<"Enter n : ";
cin>>n;
bool flag = true; //true means prime
for(int i=2;i<n;i++){
if(n%i==0){
flag = false;
break;
}
}
if(flag){
cout<<"Prime"<<endl;
}
else{
cout<<"Not Prime"<<endl;
}
int number;
// The loop will continue until the user enters a negative number
do {
std::cout << "Enter a number (negative to quit): ";
std::cin >> number;
// If the number is not negative, print it
if (number >= 0) {
std::cout << "You entered: " << number << std::endl;
}
} while (number >= 0); // Continue if the number is non-negative
std::cout << "Loop terminated." << std::endl;
//pattern printing
// to make rectangle
int m;
cout<<"Enter number of rows : ";
cin>>m;
int n;
cout<<"Enter number of columns : ";
cin>>n;
for(int i=1;i<=m;i++){ //rows = m
for(int j=1;j<=n;j++){ //columns = n
cout<<"* ";
}
cout<<endl;
}
int n;
cout<<"Enter side of a number : ";
//to make triangle
int n;
cout<<"Enter number of rows : ";
cin>>n;
for(int i=1;i<=n;i++){ //rows = n
for(int j=1;j<=i;j++){ //columns = i
cout<<j+30<<" ";
}
cout<<endl;
}
int z;
cout<<"Enter number of rows : ";
cin>>z;
for(int i=1;i<=m;i++){ //rows = m
for(int j=1;j<=i;j++){ //columns = i
cout<<2*j-1<<" ";
}
cout<<endl;
}
int rows;
cout << "Enter number of rows: ";
cin >> rows;
// Outer loop for each row
for (int i = 1; i <= rows; ++i) {
// Inner loop for printing stars
for (int j = 1; j <= i; ++j) {
cout << "* ";
}
cout << endl; // Move to the next line after each row
}
int height = 9; // Height of the letter "K"
int width = 5; // Width for the space in "K"
// Characters for each diagonal in "K"
char chars[] = {'k', 'r', 'i', 's', 'h', 'n', 'a'};
// Loop for the first diagonal of "K" (top half and middle part)
for (int i = 0; i < height / 2 + 1; i++) {
cout << "k";
// Print spaces before the next character in the row
for (int j = 0; j < width - i - 1; j++) {
cout << " ";
}
// Print the second part (if not the center line)
if (i != height / 2) {
cout << chars[i];
}
cout << endl;
}
// Loop for the second diagonal of "K" (bottom half)
for (int i = 1; i <= height / 2; i++) {
cout << "k";
// Print spaces before the second part
for (int j = 0; j < i; j++) {
cout << " ";
}
cout << chars[height / 2 + i] << endl;
}
//Functions
cout << "Good Morning" << endl;
cout << "How are you?\nWhat are you doing?" << endl;
//Pointers
int num = 10; // A simple integer variable
int* ptr = # // Pointer variable that holds the address of 'num'
// Printing the value of 'num'
cout << "Value of num: " << num << endl;
// Printing the address of 'num'
cout << "Address of num: " << &num << endl;
// Printing the value stored in pointer 'ptr' (which is the address of 'num')
cout << "Pointer ptr holds the address: " << ptr << endl;
// Dereferencing the pointer to access the value at the address it points to
cout << "Value pointed by ptr (dereferencing): " << *ptr << endl;
// Modifying the value of 'num' using the pointer
*ptr = 20;
// Printing the modified value of 'num'
cout << "Modified value of num: " << num << endl;
//Arrays
int arr[5] = {1, 2, 3, 4, 5};
arr[0] = 10;
arr[1] = 20;
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;
cout << arr[0] << " ";
cout << arr[1] << " ";
cout << arr[2] << " ";
cout << arr[3] << " ";
cout << arr[4] << " ";
//Printing the array elements
for(int i = 0; i < 5; i++){
cout << arr[i] << " ";
}
// void India(){
// cout << "India is my country" << endl;
// }
// void greet() {
// }
greet();
return 0;
}
73)Math solver API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Solver</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
body{
width: 100%;
height: 100%;
background-color: rgb(27, 33, 39);
display: flex;
justify-content: start;
align-items: center;
flex-direction: column;
padding: 20px;
gap: 20px;
}
h1{
color: white;
font-size: 4vw;
margin-bottom: 20px;
background: linear-gradient(to right, white, rgb(9,192,216), rgb(215,12,94));
background-clip: text;
-webkit-text-fill-color: transparent;
}
.upload-image{
max-width: 600px;
width: 90%;
height: 300px;
background-color: rgb(66, 76, 86);
border-radius: 50px;
box-shadow: 2px 2px 10px black;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
flex-direction: column;
color: white;
font-size: 20px;
transition: all 0.3s;
}
.inner-upload-image{
width: 100%;
height: 80%;
background-color: rgb(21, 26, 32);
border-radius: 50px;
box-shadow: 2px 2px 10px black;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 20px;
position: relative;
overflow: hidden;
color: white;
font-size: 20px;
transition: all 0.3s;
cursor: pointer;
}
img{
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50px;
}
button{
background-color: black;
padding: 10px 20px;
font-size: 20px;
border: none;
border-radius: 20px;
color: white;
cursor: pointer;
transition: all 0.3s;
}
input[type="file"] {
display: none;
}
.upload-label {
background-color: black;
color: white;
padding: 10px 20px;
font-size: 16px;
border-radius: 20px;
cursor: pointer;
}
.inner-upload-image:hover{
box-shadow:inset 2px 2px 10px black;
background-color: rgb(42, 51, 62);
}
.output-area {
display: none;
background-color: rgb(66, 76, 86);
color: white;
padding: 20px;
margin-top: 20px;
border-radius: 10px;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Hey! I am Your Math Solver</h1>
<div class="upload-image">
<div class="inner-upload-image" id="upload-area">
<img id="uploaded-image" src="" alt="Upload Image" style="display:none;">
<label for="file-upload" class="upload-label">Choose Image</label>
</div>
<input type="file" id="file-upload" accept="image/*">
<button id="solve-btn">Solve</button>
</div>
<div class="output-area" id="output-area">
<h2>Solution:</h2>
<p id="solution-text"></p>
</div>
</body>
<script>
const input = document.getElementById('file-upload');
const uploadedImage = document.getElementById('uploaded-image');
const solveBtn = document.getElementById('solve-btn');
const solutionText = document.getElementById('solution-text');
const outputArea = document.getElementById('output-area');
let fileDetails = { mime_type: null, data: null };
input.addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
uploadedImage.src = e.target.result;
uploadedImage.style.display = 'block';
fileDetails.mime_type = file.type;
fileDetails.data = e.target.result.split(',')[1]; // Get base64 data
};
reader.readAsDataURL(file);
}
});
// Function to call the API
async function callMathSolverApi(fileDetails) {
const apiKey = // Replace with actual API key
const apiUrl = // Replace with actual API endpoint
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}` // Assuming API uses Bearer token
},
body: JSON.stringify({
contents: [
{
parts: [
{ text: 'solve the mathematical problem with proper steps of solution' },
{
inline_data: {
mime_type: fileDetails.mime_type,
data: fileDetails.data
}
}
]
}
]
})
};
try {
const response = await fetch(apiUrl, requestOptions);
const data = await response.json();
const apiResponse = data.candidates[0].content.parts[0].text.replace(/\*\*(.*?)\*\*/g, "$1").trim();
solutionText.innerHTML = apiResponse;
outputArea.style.display = 'block';
} catch (error) {
console.error('Error:', error);
}
}
solveBtn.addEventListener('click', function() {
if (fileDetails.mime_type && fileDetails.data) {
callMathSolverApi(fileDetails);
} else {
alert('Please upload an image first!');
}
});
</script>
</html>
*Not Done
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Solver</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
body{
width: 100%;
height: 100%;
background-color: rgb(27, 33, 39);
display: flex;
justify-content: start;
align-items: center;
flex-direction: column;
padding: 20px;
gap: 20px;
}
h1{
color: white;
font-size: 4vw;
margin-bottom: 20px;
background: linear-gradient(to right, white, rgb(9,192,216), rgb(215,12,94));
background-clip: text;
-webkit-text-fill-color: transparent;
}
.upload-image{
max-width: 600px;
width: 90%;
height: 300px;
background-color: rgb(66, 76, 86);
border-radius: 50px;
box-shadow: 2px 2px 10px black;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
flex-direction: column;
color: white;
font-size: 20px;
transition: all 0.3s;
}
.inner-upload-image{
width: 100%;
height: 80%;
background-color: rgb(21, 26, 32);
border-radius: 50px;
box-shadow: 2px 2px 10px black;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 20px;
position: relative;
overflow: hidden;
color: white;
font-size: 20px;
transition: all 0.3s;
cursor: pointer;
}
img{
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50px;
}
button{
background-color: black;
padding: 10px 20px;
font-size: 20px;
border: none;
border-radius: 20px;
color: white;
cursor: pointer;
transition: all 0.3s;
}
input[type="file"] {
display: none;
}
.upload-label {
background-color: black;
color: white;
padding: 10px 20px;
font-size: 16px;
border-radius: 20px;
cursor: pointer;
}
.inner-upload-image:hover{
box-shadow:inset 2px 2px 10px black;
background-color: rgb(42, 51, 62);
}
.output-area {
display: none;
background-color: rgb(66, 76, 86);
color: white;
padding: 20px;
margin-top: 20px;
border-radius: 10px;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Hey! I am Your Math Solver</h1>
<div class="upload-image">
<div class="inner-upload-image" id="upload-area">
<img id="uploaded-image" src="" alt="Upload Image" style="display:none;">
<label for="file-upload" class="upload-label">Choose Image</label>
</div>
<input type="file" id="file-upload" accept="image/*">
<button id="solve-btn">Solve</button>
</div>
<div class="output-area" id="output-area">
<h2>Solution:</h2>
<p id="solution-text"></p>
</div>
</body>
<script>
let innerUploadImage=document.querySelector("a.inner-upload-image")
let input=innerUploadImage.querySelector("input")
let image=document.querySelector("img.inner-upload-image")
let btn=document.querySelector("button")
let text=document.querySelector("#text")
let output=document.querySelector(".output")
// Function to call the API
async function callMathSolverApi(imageData) {
const apiKey = // Replace with actual API key
const apiUrl = // Replace with actual API endpoint
let fileDetailes={
mime_type: null,
data: null,
}
async function generateResponse(fileDetails) {
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contents: [
{
parts: [
{ text: 'solve the mathematical problem with proper steps of solution' },
{
inline_data: {
mime_type: fileDetails.mime_type,
data: fileDetails.data
}
}
]
}
]
})
};
try {
let response=await fetch(Api_url,RequestOption)
let data=await response.json()
let apiResponse=data.candidates[0].content.parts[0].text.replace(/\*\*(.*?)\*\*/g,"$1").trim()
text.innerHTML=apiResponse
output.style.display="block"
}catch(e){
console.log(e)
}
finally{
output
}
}
</Script>
</html>
74)Engineering math .py matrices
print(" write the value of 1st matrix: ")
a = int(input ("Enter the value of a: "))
b = int(input ("Enter the value of b: "))
c = int(input ("Enter the value of c: "))
d = int(input ("Enter the value of d: "))
e = int(input ("Enter the value of e: "))
f = int(input ("Enter the value of f: "))
g = int(input ("Enter the value of g: "))
h = int(input ("Enter the value of h: "))
i = int(input ("Enter the value of i: "))
print(" write the value of 2nd matrix: ")
j = int(input ("Enter the value of j: "))
k = int(input ("Enter the value of k: "))
l = int(input ("Enter the value of l: "))
m = int(input ("Enter the value of m: "))
n = int(input ("Enter the value of n: "))
o = int(input ("Enter the value of o: "))
p = int(input ("Enter the value of p: "))
q = int(input ("Enter the value of q: "))
r = int(input ("Enter the value of r: "))
x = [[a,b,c],
[d,e,f],
[g,h,i]]
y = [[j,k,l],
[m,n,o],
[p,q,r]]
result =[[x[i][j] + y[i][j] for j in range(len(x[0]))] for i in range(len(x))]
for r in result:
print(r)
*)
x = [[1,6,6],
[8,4,7],
[4,6,7]]
y = [[2,6,7],
[8,4,9],
[5,7,7]]
result =[[x[i][j] + y[i][j] for j in range(len(x[0]))] for i in range(len(x))]
for r in result:
print(r)
75)MY PORTFOLIO 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Krishna Portfolio</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Georgia, 'Times New Roman', Times, serif;
}
body {
background-color: rgb(17, 20, 23);
color: white;
scroll-behavior: smooth;
}
nav {
position: fixed;
top: 0;
width: 100%;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
background-color: rgba(17, 20, 23);
z-index: 20;
}
nav h1 {
font-size: 40px;
background: linear-gradient(to right, rgb(66, 180, 205), white);
background-clip: text;
color: transparent;
}
.desktopmenu {
display: flex;
align-items: center;
gap: 20px;
list-style: none;
}
.desktopmenu li a,
.mobilemenu li a {
color: white;
text-decoration: none;
font-size: 18px;
transition: color 0.3s ease;
}
.desktopmenu li a:hover,
.mobilemenu li a:hover {
color: rgb(66, 180, 205);
}
.hamburger {
align-items: center;
display: flex;
justify-content: center;
flex-direction: column;
gap: 8px;
cursor: pointer;
}
nav ul a{
cursor:pointer;
}
nav ul a:hover{
color:rgb(107, 211, 211);
border-bottom: 2px solid white;
}
.active{
color: rgb(107,211,211);
border-bottom:2px solid white;
}
nav ul{
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
color: white;
list-style: none;
font-size: 20px;
}
.ham {
width: 40px;
height: 2px;
background-color: white;
transition: all 0.5s;
}
.mobilemenu {
display: none;
flex-direction: column;
list-style: none;
position: absolute;
top: 80px;
right: 0;
width: 100%;
background-color: rgba(17, 20, 23, 0.95);
backdrop-filter: blur(7px);
padding: 20px;
gap: 20px;
}
.activemobile {
display: flex;
}
.activeham .ham:nth-child(1) {
transform: rotate(45deg);
position: relative;
top: 8px;
}
.activeham .ham:nth-child(2) {
opacity: 0;
}
.activeham .ham:nth-child(3) {
transform: rotate(-45deg);
position: relative;
top: -13px;
}
@media (max-width: 750px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
}
}
section {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px; /* Adjusted for smaller text */
}
#home {
background-color: rgb(0, 0, 0);
}
#about {
background-color: rgb(0, 0, 0);
}
#projects {
background-color: rgb(0, 0, 0);
}
#contact {
background-color: rgb(0, 0, 0);
}
#website {
background-color: rgb(0, 0, 0);
}
#homepage {
width: 100%;
height: 100%;
display: flex;
}
.lefthome {
width: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.righthome {
width: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.righthome img {
width: 60%;
filter: drop-shadow(2px 2px 20px rgb(116, 201, 225));
}
.homedetails {
font-size: 3vmax; /* Adjusted for smaller text */
}
/* .line1 {
font-size: 0.7em;
}
.line2 {
font-size: 2.2em;
background: linear-gradient(to right, rgb(66, 180, 205), white);
background-clip: text;
color: transparent;
}
.line3 {
font-size: 2em;
font-weight: bold;
background: linear-gradient(90deg, rgba(66, 180, 205, 1), rgba(198, 42, 96, 1));
background-clip: text;
color: transparent;
display: inline-block;
white-space: nowrap;
border-right: 3px solid #fff; /* Simulates the cursor
animation: typewriter 5s steps(20) 1s infinite, blink 0.75s step-end infinite;
}
@keyframes typewriter {
from {
width: 0;
}
to {
width: 100%;
}
}
@keyframes blink {
50% {
border-color: transparent;
}
} */
.homedetails {
text-align: center;
padding: 30px;
}
.line1 {
font-size: 0.7em;
color: #fff;
margin-bottom: 10px;
}
.line2 {
font-size: 2.2em;
background: linear-gradient(to right, rgb(66, 180, 205), white);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
margin-bottom: 20px;
}
.line3 {
font-size: 2em;
font-weight: bold;
background: linear-gradient(90deg, rgba(66, 180, 205, 1), rgba(198, 42, 96, 1));
background-clip: text;
-webkit-background-clip: text;
color: transparent;
display: inline-block;
border-right: 3px solid #fff;
white-space: nowrap;
overflow: hidden;
animation: typewriter 5s steps(20) 1s infinite, blink 0.75s step-end infinite;
}
@keyframes typewriter {
from {
width: 0;
}
to {
width: 100%;
}
}
@keyframes blink {
50% {
border-color: transparent;
}
}
.homedetails button {
padding: 10px 30px;
background-color: rgb(66, 180, 205);
color: black;
border: 2px solid white;
border-radius: 5px;
margin: 30px;
border-radius:20px;
font-size: 19px;
transition:all 0.2s;
cursor: pointer;
}
.homedetails button:hover{
background-color: transparent;
color: rgb(66,180, 205);
}
@media (max-width: 750px) {
#home{
flex-direction: column;
}
.lefthome{
width: 100%;
height: 50vh;
}
.righthome{
width: 100%;
}
}
@keyframes typing {
from {
width: 0;
}
to {
width: 100%;
}
}
@keyframes blink {
from {
border-color: transparent;
}
to {
border-color: white;
}
}
#about{
width: 100%;
height: 100%;
display: flex;
}
.leftabout{
width: 50%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
gap:40px;
}
/* .circle-line{
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
} */
/* .circle{
width: 60px;
height: 60px;
border-radius: 50px;
background-color: #7ad7ea;
box-shadow: 2px 2px 20px #7ad7ea;
} */
/*.line{
width: 2px;
height: 120px;
background-color: aliceblue;
} */
.aboutdetails{
display: flex;
gap: 40px;
flex-direction: column;
}
.aboutdetails ul{
list-style: none;
}
.aboutdetails h1{
background: linear-gradient(to right, rgb(198, 42, 96), white);
background-clip: text;
color: transparent;
}
.aboutdetails li{
color: white;
}
.aboutdetails span{
color: #7ad7ea;
}
.card{
width: 90%;
max-width: 400px;
height: 150px;
background-color: rgb(20, 26, 31);
position: relative;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
box-shadow: 2px 2px 10px black,2px 2px 20px black;
border-radius: 10px;
transition:all 02s;
cursor: pointer;
flex-shrink: 0;
padding: 10px;
}
.card:hover{
box-shadow: 2px 2px 10px rgb(87, 195, 219),2px 2px 20px rgb(82, 205, 207);
}
.hovercard img{
height: 80%;
filter: drop-shadow(2px 2px 10px black);
}
.hovercard{
width: 100px;
height: 100%;
background: lenier-gradient(to top, rgba(121, 205, 220, 0.486),rgba(12,17,20,0.495));
position: absolute;
bottom: 0;
transform:translateY(-100%);
transition: all 0.5s;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(7px);
}
.card:hover .hovercard{
transform: translateY(0%);
}
.card h1{
background: linear-gradient(to right, rgb(42, 198, 195), white);
background-clip: text;
color: transparent;
}
.rightabout{
width: 50%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 30px;
}
@media (max-width:750px){
#about{
flex-direction: column;
}
.leftabout{
width: 100%;
padding: 10%;
}
.rightabout{
width: 100%;
}
}
#projects{
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 30px;
}
.slider {
width: 90%;
height: 300px;
display: flex;
align-items: center;
overflow-x: auto; /* Allows smooth horizontal scrolling */
overflow-y: hidden;
gap: 30px;
padding: 20px;
scroll-behavior: smooth; /* Adds smooth scrolling effect */
}
#para {
font-size: 4vmax;
background: linear-gradient(to right, rgb(203, 53, 108), white);
background-clip: text;
color: transparent;
text-align: center; /* Centers text horizontally */
display: flex;
justify-content: center; /* Centers text horizontally within flex container */
align-items: center; /* Centers text vertically within flex container */
height: 10vh; /* Adjust height to center vertically within the viewport */
}
#contact{
width: 100%;
height: 100%;
display: flex;
}
.leftcontact{
width: 50%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.leftcontact img {
width: 80%;
filter:drop-shadow(2px 2px 10px rgba(87,196,220))
}
.rightcontact {
width: 50%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
/*
form {
width: 80%;
max-width: 400px;
background-color: rgb(19, 25, 29);
box-shadow: 2px 2px 10px black, 2px 2px 20px black;
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px;
border-radius: 20px;
margin: auto;
} */
form:hover {
box-shadow: 2px 2px 10px rgb(105, 208, 215), 2px 2px 20px rgb(105, 208, 215);
}
form input,
form textarea {
width: 100%;
border: 2px solid rgb(105, 208, 215);
border-radius: 20px;
padding: 15px;
outline: none;
font-size: 16px;
}
#textarea {
height: 150px;
}
#btn {
width: 100%;
height: 50px;
background-color: rgb(105, 208, 215);
border: none;
border-radius: 20px;
color: #000;
font-size: 18px;
cursor: pointer;
transition: all 0.3s ease;
}
#btn:hover {
background: transparent;
color: rgb(105, 208, 215);
border: 2px solid rgb(105, 208, 215);
}
@media (max-width: 750px) {
form {
width: 90%;
padding: 15px;
}
.leftcontact img {
width: 100%;
}
.rightcontact {
width: 100%;
}
}
#website {
text-align: center;
padding: 10px;
background-color: #000; /* Black background */
border-radius: 10px;
}
#website h1 {
font-size: 1.8em;
color: #fff;
margin: 0; /* Remove bottom margin to keep lines close */
text-align: center;
}
#web {
margin: 0; /* Remove default margin on h3 */
}
#web a {
font-size: 1.3em;
color: #00ffcc;
text-decoration: none;
font-weight: bold;
}
#web a:hover {
color: #ff6600;
text-decoration: underline;
}
</style>
</head>
<body>
<nav>
<h1>PORTFOLIO</h1>
<ul class="desktopmenu">
<li><a href="#home">HOME</a></li>
<li><a href="#about">ABOUT</a></li>
<li><a href="#projects">PROJECTS</a></li>
<li><a href="#contact">CONTACT US</a></li>
<li><a href="#website">MY WEBSITE</a></li>
</ul>
<div class="hamburger" onclick="toggleMenu()">
<div class="ham"></div>
<div class="ham"></div>
<div class="ham"></div>
</div>
<ul class="mobilemenu">
<li><a href="#home" onclick="toggleMenu()">HOME</a></li>
<li><a href="#about" onclick="toggleMenu()">ABOUT</a></li>
<li><a href="#projects" onclick="toggleMenu()">PROJECTS</a></li>
<li><a href="#contact" onclick="toggleMenu()">CONTACT US</a></li>
<li><a href="#website" onclick="toggleMenu()">MY WEBSITE</a></li>
</ul>
</nav>
<main>
<section id="home">
<div id="homepage">
<div class="lefthome">
<div class="homedetails">
<div class="line1">I'M</div>
<div class="line2">KRISHNA PATIL RAJPUT</div>
<div class="line3">BLOGGER</div>
<br>
<button>HIRE ME</button>
</div>
</div>
<div class="righthome">
<img src="your-image-path.jpg" alt="Image of Krishna" />
</div>
</div>
</section>
<section id="about">
<div id="#about">
<div className="leftabout">
<div class="circle-line">
<div class="circle"></div>
<div class="line"></div>
<div class="circle"></div>
<div class="line"></div>
<div class="circle"></div>
</div>
<div class="aboutdetails">
<div class="personalinfo">
<h1>Personal Info</h1>
<ul>
<li>
<span>Name</span> : KRISHNA PATIL RAJPUT
</li>
<li>
<span>AGE</span> : 18 YEARS
</li>
<li>
<span>GENDER</span> : MALE
</li>
<li>
<span>LANGUAGE KNOWN</span> : HINDI,MARATHI,ENGLISH
</li>
</ul>
</div>
<div class="EDUCATION">
<h1>Education</h1>
<ul>
<li>
<span>DEGREE</span> : B-TECH
</li>
<li>
<span>BRANCH</span> : INFORMATION TECHNOLOGY & ENGINEERING
</li>
<li>
<span>CGPA</span> : 8.2
</li>
</ul>
</div>
<div class="Skills">
<h1>Skills</h1>
<ul>
<li>
BEGINNER OF REACT
</li>
<li>
PYTHON
</li>
<li>
JAVA , HTML,CSS,JS,JSX
</li>
</ul>
</div>
</div>
<div className="rightabout">
<div class="card">
<h1>Bigginner developer</h1>
<div class="hovercard">
<img src="http://placehold.it/" alt"">
</div>
</div>
<div class="card">
<h1>PYTHON</h1>
<div class="hovercard">
<img src="http://placehold.it/" alt"">
</div>
</div>
<div class="card">
<h1>HTML,CSS,JS,JSX</h1>
<div class="hovercard">
<img src="http://placehold.it/" alt"">
</div>
</div>
</div>
</div>
</section>
<section id="projects">
<div class="projects">
<h1 id="para">Matoshri ENGINEERING STUDENT PROJECTS</h1>
<div class="slider">
<div class="card">
<h1>Virtual ASSISTANT</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/chatbot-and-voice-assistant-combination.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>AI CHATBOT</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/chatbot-jarvis.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>AI TEXT TO IMAGE GENERATOR</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/image-generator.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>AI BACKGROUND REMOVER</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/background-remover-app.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>SEARCH IMAGE ENGINE</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/search-image-engine.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>ALL CODES FOR BINGGINER 1</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/2024/06/all-codes-for-beginner.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>ALL CODES FOR BINGGINER 2</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/2024/08/all-codes-for-beginner.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>TRANSLATE APP</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/translate-app.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>ANHANCED SCIENTIFIC CALCULATOR</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/enhanced-scientific-calculator.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
<div class="card">
<h1>CURRENCY CONVERTER APP</h1>
<div class="hovercard">
<a href="https://krishnablogy.blogspot.com/p/currency-converter-app.html" target="_blank">
<img src="http://placehold.it/300x200" alt="Virtual Assistant Image">
</a>
</div>
</div>
</div>
</div>
</section>
<section id="contact">
<div class="contact">
<div class="leftcontact">
<img src="" alt="" />
</div>
<!-- <div class="rightcontact">
<form action="" method="POST">
<input name="Username" type="text" placeholder="Name"/>
<input name="Email" type="Email" placeholder="Email"/>
<textarea name="Message" placeholder="Message me"></textarea>
<input type="submit" id="btn" value="Submit"/>
</form>
</div> -->
<div class="rightcontact">
<form action=" https://formspree.io/f/mrbgrkre" method="POST">
<input name="Username" type="text" placeholder="Name" required />
<input name="Email" type="email" placeholder="Email" required />
<textarea id="textarea" name="Message" placeholder="Message me" required></textarea>
<input type="submit" id="btn" value="Submit" />
</form>
</div>
</div>
</section>
<section id="website">
<h1>Visit My Website: </h1>
<h3 id="web">
<a href="https://krishnablogy.blogspot.com" target="_blank">KRISHNABLOGY.BLOGSPOT.COM</a>
</h3>
</section>
</main>
<script>
function toggleMenu() {
document.querySelector('.mobilemenu').classList.toggle('activemobile');
document.querySelector('.hamburger').classList.toggle('activeham');
}
</script>
</body>
</html>
76)WELCOME TO MARS...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mars</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&display=swap');
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Georgia, 'Times New Roman', Times, serif;
}
body {
background-image: url('space.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
color: white;
scroll-behavior: smooth;
font-family: 'Nunito', sans-serif;
overflow-x: hidden;
}
.container {
position: relative;
margin: 0 auto;
height: 100vh;
padding: 20px;
}
@media screen and (max-width: 768px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
}
}
.hamburger {
display: none;
cursor: pointer;
}
@media screen and (max-width: 768px) {
.hamburger {
display: flex;
align-items: center;
justify-content: center;
font-size: 30px;
color: white;
}
.desktopmenu {
display: none;
}
}
/* Toggle menu visibility */
.hamburger.active+.desktopmenu {
display: flex;
flex-direction: column;
}
/*mars menu*/
.mars {
position: absolute;
animation: movement 60s linear infinite;
width: 20rem;
/* default size */
max-width: 100%;
/* Ensures it scales with screen size */
}
@media screen and (max-width: 768px) {
.mars {
width: 15rem;
/* Adjust the size for smaller screens */
}
}
/* Menu close*/
html {
scroll-behavior: smooth;
}
footer {
background-color: #222;
color: #fff;
font-size: 14px;
text-align: center;
padding: 10px;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
}
#home, #Info, #projects, #Launch-Shedule, #contact-us {
background-color: rgb(0, 0, 0);
}
#homepage {
width: 100%;
height: 100%;
display: flex;
}
.desktopmenu, .mobilemenu {
list-style: none;
padding: 0;
}
.desktopmenu {
display: flex;
align-items: center;
gap: 20px;
}
.desktopmenu li a,
.mobilemenu li a {
color: white;
text-decoration: none;
font-size: 18px;
transition: color 0.3s ease;
}
.desktopmenu li a:hover,
.mobilemenu li a:hover {
color: rgb(66, 180, 205);
}
.hamburger {
display: none;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 8px;
cursor: pointer;
}
nav ul {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
color: white;
list-style: none;
font-size: 20px;
}
nav ul a {
cursor: pointer;
}
nav ul a:hover {
color: rgb(107, 211, 211);
border-bottom: 2px solid white;
}
.active {
color: rgb(107, 211, 211);
border-bottom: 2px solid white;
}
.ham {
width: 40px;
height: 2px;
background-color: white;
transition: all 0.5s;
}
.mobilemenu {
display: none;
flex-direction: column;
position: absolute;
top: 80px;
right: 0;
width: 100%;
background-color: rgba(17, 20, 23, 0.95);
backdrop-filter: blur(7px);
padding: 20px;
gap: 20px;
}
.activemobile {
display: flex;
}
.activeham .ham:nth-child(1) {
transform: rotate(45deg);
position: relative;
top: 8px;
}
.activeham .ham:nth-child(2) {
opacity: 0;
}
.activeham .ham:nth-child(3) {
transform: rotate(-45deg);
position: relative;
top: -13px;
}
@media (max-width: 750px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
}
.mobilemenu {
display: flex;
}
}
nav {
position: fixed;
top: 0;
width: 100%;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
background-color: rgba(17, 20, 23);
z-index: 20;
}
nav h1 {
font-size: 40px;
background: linear-gradient(to right, rgb(66, 180, 205), white);
background-clip: text;
color: transparent;
}
.desktopmenu {
display: flex;
align-items: center;
gap: 20px;
list-style: none;
}
.desktopmenu li a,
.mobilemenu li a {
color: white;
text-decoration: none;
font-size: 18px;
transition: color 0.3s ease;
}
.desktopmenu li a:hover,
.mobilemenu li a:hover {
color: rgb(66, 180, 205);
}
.hamburger {
align-items: center;
display: flex;
justify-content: center;
flex-direction: column;
gap: 8px;
cursor: pointer;
}
/*scroll down*/
@media screen and (max-width: 768px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 30px;
height: 20px;
cursor: pointer;
}
.hamburger div {
background-color: white;
height: 3px;
width: 100%;
transition: all 0.3s ease;
}
.hamburger.active div:nth-child(1) {
transform: rotate(45deg);
transform-origin: top left;
}
.hamburger.active div:nth-child(2) {
opacity: 0;
}
.hamburger.active div:nth-child(3) {
transform: rotate(-45deg);
transform-origin: bottom left;
}
.desktopmenu.active {
display: flex;
flex-direction: column;
position: absolute;
top: 80px;
left: 0;
background-color: rgba(17, 20, 23, 0.9);
width: 100%;
padding: 20px;
transition: all 0.3s ease;
}
.desktopmenu li a {
font-size: 18px;
}
}
/* scroll down close*/
.ham {
width: 40px;
height: 2px;
background-color: white;
transition: all 0.5s;
}
.mobilemenu {
display: none;
flex-direction: column;
list-style: none;
position: absolute;
top: 80px;
right: 0;
width: 100%;
background-color: rgba(17, 20, 23, 0.95);
backdrop-filter: blur(7px);
padding: 20px;
gap: 20px;
}
.activemobile {
display: flex;
}
.activeham .ham:nth-child(1) {
transform: rotate(45deg);
position: relative;
top: 8px;
}
.activeham .ham:nth-child(2) {
opacity: 0;
}
.activeham .ham:nth-child(3) {
transform: rotate(-45deg);
position: relative;
top: -13px;
}
@media (max-width: 750px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
}
}
section {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px; /* Adjusted for smaller text */
}
#home {
background-color: rgb(0, 0, 0);
}
#Info {
background-color: rgb(0, 0, 0);
}
#projects {
background-color: rgb(0, 0, 0);
}
#Launch-Schedule {
background-color: rgb(0, 0, 0);
}
#Contact-Us {
background-color: rgb(0, 0, 0);
}
.ham {
width: 40px;
height: 2px;
background-color: white;
transition: all 0.5s;
}
.mobilemenu {
display: none;
flex-direction: column;
list-style: none;
position: absolute;
top: 80px;
right: 0;
width: 100%;
background-color: rgba(17, 20, 23, 0.95);
backdrop-filter: blur(7px);
padding: 20px;
gap: 20px;
}
.activemobile {
display: flex;
}
.activeham .ham:nth-child(1) {
transform: rotate(45deg);
position: relative;
top: 8px;
}
.activeham .ham:nth-child(2) {
opacity: 0;
}
.activeham .ham:nth-child(3) {
transform: rotate(-45deg);
position: relative;
top: -13px;
}
@media (max-width: 750px) {
.desktopmenu {
display: none;
}
.hamburger {
display: flex;
}
}
.hamburger {
align-items: center;
display: flex;
justify-content: center;
flex-direction: column;
gap: 8px;
cursor: pointer;
}
h4 {
color: red;
width: 600px;
}
body {
font-family: 'Nunito', sans-serif;
color: white;
overflow: hidden;
background-color: black;
}
.bg-img {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url(/images/space.jpg) no-repeat fixed center;
background-size: cover;
animation: scaling 60s linear infinite;
}
@keyframes scaling {
0% {
transform: scale(1);
}
50% {
transform: scale(2);
}
100% {
transform: scale(1);
}
}
.bg-img::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
}
a {
text-decoration: none;
color: white;
}
ol {
list-style-type: none;
display: flex;
}
.container {
position: relative;
max-width: 1200px;
margin: 0 auto;
height: 100vh;
}
.mars {
position: absolute;
animation: movement 60s linear infinite;
}
@keyframes movement {
0% {
width: 20rem;
top: 10%;
right: 30%;
transform: rotate(0deg);
}
50% {
width: 50rem;
top: 20%;
right: -10%;
transform: rotate(180deg);
}
100% {
width: 20rem;
top: 10%;
right: 30%;
transform: rotate(360deg);
}
}
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 50px 0;
}
header>a {
font-weight: 700;
font-size: 24px;
text-transform: uppercase;
letter-spacing: 3px;
}
header ol li {
font-weight: 600;
padding: 0 20px;
opacity: 0.6;
}
header ol li:first-child {
opacity: 1;
}
h1 {
font-size: 54px;
}
main {
padding-top: 5%;
}
main>p {
max-width: 50%;
opacity: 0.75;
font-size: 13px;
}
.d-flex {
display: flex;
margin-top: 20px;
margin-bottom: 50px;
}
.d-flex a {
margin-right: 50px;
display: flex;
font-size: 14px;
align-items: center;
text-transform: uppercase;
}
.d-flex a span {
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
margin-right: 5px;
}
.d-flex a:first-child span {
background: maroon;
width: 30px;
height: 30px;
border-radius: 50%;
}
.d-flex a:last-child span {
height: 20px;
width: 20px;
font-size: 7px;
border: 2px solid white;
border-radius: 50%;
}
ul.info {
padding-top: 5%;
}
l.info li {
flex: 0 0 30%;
}
ol.info li h5 {
margin-bottom: 10px;
}
ol.info li h4 {
margin-bottom: 10px;
}
ol.info li p {
padding-right: 20%;
opacity: 0.75;
}
footer {
background-color: #222;
color: #fff;
font-size: 14px;
bottom: 0;
position: fixed;
left: 0;
right: 0;
text-align: center;
z-index: 999;
}
footer p {
margin: 5px 0;
}
footer i {
color: red;
margin: 0 10px;
}
footer a {
color: greenyellow;
text-decoration: none;
}
.explore-mars-button {
display: inline-block;
background-color: #ff4500;
/* Mars-like red */
color: white;
padding: 10px 20px;
font-size: 18px;
font-weight: bold;
border: none;
border-radius: 5px;
text-decoration: none;
text-align: center;
transition: background-color 0.3s ease, transform 0.2s ease;
}
.explore-mars-button:hover {
background-color: #e63900;
/* Slightly darker red */
transform: scale(1.05);
/* Adds a zoom-in effect on hover */
box-shadow: 0 4px 15px rgba(255, 69, 0, 0.5);
/* Adds a glowing effect */
}
.explore-mars-button:active {
background-color: #cc3300;
/* Even darker red */
transform: scale(1);
}
/* General styles for the ordered list */
.info {
list-style: none;
/* Remove default list styling */
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
/* Make the list items stack vertically */
align-items: flex-start;
/* Align items to the left */
}
/* Styling each item in the list */
.info .item {
margin-bottom: 20px;
/* Add spacing between items */
padding: 0;
/* Remove inner spacing for items */
border: none;
/* Remove borders */
background-color: transparent;
/* Fully transparent boxes */
width: 100%;
/* Make the boxes take full width */
}
/* Styling the numbering (h5) */
.info .item h5 {
font-size: 20px;
/* Number font size */
font-weight: bold;
/* Make numbers bold */
color: #d32f2f;
/* Red color for numbers */
margin: 0 0 5px;
/* Add space below numbers */
background-color: transparent;
/* Transparent background for numbers */
display: inline-block;
/* Keep numbers inline */
}
/* Styling the heading (h4) */
.info .item h4 {
font-size: 18px;
/* Heading font size */
color: violet;
/* Dark gray color for text */
margin: 0 0 10px;
/* Add space below the heading */
background-color: transparent;
/* Transparent background for headings */
display: block;
/* Ensure headings are block-level elements */
}
/* Styling the description paragraph */
.info .item p {
font-size: 16px;
/* Paragraph font size */
color: white;
/* Medium gray text color */
line-height: 1.6;
/* Increase line spacing for readability */
margin: 0 0 10px;
/* Add space below the paragraph */
background-color: transparent;
/* Transparent background for paragraph */
}
/* Styling the unordered lists inside items */
.info .item ul {
margin: 10px 0 0 20px;
/* Indentation for list items */
padding: 0;
background-color: transparent;
/* Transparent background for the list */
}
/* Styling the individual list items */
.info .item ul li {
font-size: 16px;
/* Font size for list items */
color: gray;
/* Slightly darker gray text */
margin-bottom: 5px;
/* Add spacing between list items */
line-height: 1.5;
/* Improve spacing between lines */
background-color: transparent;
/* Transparent background for list items */
}
/* Highlighting bold text inside the list */
.info .item ul li strong {
color: #2e7d32;
/* Green color for emphasis */
background-color: transparent;
/* Transparent background for bold text */
}
</style>
</head>
<body>
<div class="hamburger">
<i class="fas fa-bars"></i>
</div>
<nav aria-label="Main Navigation">
<div class="hamburger" aria-label="Open menu" tabindex="0" onclick="toggleMenu()">
<div></div>
<div></div>
<div></div>
</div>
<h1 href="#">Mars</h1>
<ul class="desktopmenu">
<li><a href="#home">HOME</a></li>
<li><a href="#about">Info</a></li>
<li><a href="#projects">PROJECTS</a></li>
<li><a href="#contact">Launch Schedule</a></li>
<li><a href="#website">Contact us</a></li>
</ul>
</nav>
<div class="hamburger" onclick="toggleMenu()">
<div class="ham"></div>
<div class="ham"></div>
<div class="ham"></div>
</div>
<ul class="mobilemenu">
<li><a href="#home" onclick="toggleMenu()">HOME</a></li>
<li><a href="#about" onclick="toggleMenu()">ABOUT</a></li>
<li><a href="#projects" onclick="toggleMenu()">PROJECTS</a></li>
<li><a href="#contact" onclick="toggleMenu()">CONTACT US</a></li>
<li><a href="#website" onclick="toggleMenu()">MY WEBSITE</a></li>
</ul>
</nav>
<span class="bg-img"></span>
<img src="mars.png" alt="Mars" class="mars">
<div class="container">
<main>
<h1>Humans live on Mars <br>is it possible?</h1>
<p>Mars might not be somewhere we could live. We are not sure how effective Mars's atmosphere would be as a
radiation shield (how will astronauts hide from radiation on Mars?) And we must remember that the
explorers will have to spend a long time on the planet. There can be no quick there-and-back dash, as
with the Moon.</p>
<div class="d-flex">
<a href="#">
<span>
<i class="fas fa-arrow-right"></i>
</span>
<a href="https://mars.nasa.gov/" target="_blank" class="explore-mars-button">
Explore Mars
</a>
</a>
<a href="#">
<span>
<i class="fas fa-play"></i>
</span>
<a href="https://youtu.be/PPgFKZvfMUU" target="_blank" class="watch-video-button">
Watch Video
</a>
</a>
</div>
<ol class="info">
<li class="item">
<h5>01</h5>
<h4>Mars: The Red Planet</h4>
<p>
Mars, often referred to as the Red Planet, is the fourth planet from the Sun in our Solar
System.
It is named after the Roman god of war due to its reddish appearance, which comes from iron
oxide (rust) on its surface.
Here's a detailed overview:
</p>
<ul>
<li><strong>Distance from the Sun:</strong> About 227.9 million kilometers (141.6 million
miles).</li>
<li><strong>Length of a Day (Sol):</strong> 24.6 hours.</li>
<li><strong>Length of a Year:</strong> 687 Earth days.</li>
<li><strong>Diameter:</strong> 6,779 kilometers (4,212 miles) – roughly half the size of Earth.
</li>
<li><strong>Gravity:</strong> 38% of Earth's gravity (you'd weigh much less on Mars!).</li>
<li><strong>Moons:</strong> Two small moons, Phobos and Deimos.</li>
</ul>
</li>
<li class="item">
<h5>02</h5>
<h4>Interesting Facts About Mars</h4>
<ul>
<li>Mars has the largest volcano in the Solar System, Olympus Mons, which is about 21.9 km (13.6
miles) high.</li>
<li>Valles Marineris, a canyon system on Mars, stretches over 4,000 km (2,500 miles).</li>
<li>Mars experiences massive dust storms that can last for weeks and cover the entire planet.
</li>
<li>Sunsets on Mars appear blue due to the way its atmosphere scatters sunlight.</li>
<li>Mars' atmosphere is 95.3% carbon dioxide, making it inhospitable for human life without
support systems.</li>
</ul>
</li>
<li class="item">
<h5>03</h5>
<h4>Water on Mars</h4>
<p>Evidence suggests Mars once had flowing rivers, lakes, and even an ocean. Today, water is mostly
found as ice in polar caps and possibly beneath the surface.</p>
<ul>
<li>Seasonal dark streaks on the surface hint at possible briny liquid water flows.</li>
<li>Subsurface ice could be a vital resource for future human missions.</li>
</ul>
</li>
<li class="item">
<h5>04</h5>
<h4>Exploration of Mars</h4>
<p>Several missions have explored Mars, including orbiters, landers, and rovers.</p>
<ul>
<li><strong>Rovers:</strong> Perseverance, Curiosity, Spirit, and Opportunity have provided
invaluable data.</li>
<li><strong>Orbiters:</strong> Mars Reconnaissance Orbiter and MAVEN continue to study the
planet from above.</li>
<li><strong>Future:</strong> Plans for human exploration by NASA and private companies like
SpaceX are underway.</li>
</ul>
</li>
</ol>
</main>
<footer>
<p>
Created with <i class="fa fa-heart"></i> by
<a target="_blank" href="https://www.youtube.com/@ATHARVA_GAMING_YT">KRISHNA
PATIL RAJPUT</a>
- @MATOSHRI COLLEGE OF ENGINEERING COLLEGE
</p>
</footer>
</div>
<script>
const hamburger = document.querySelector('.hamburger');
const menu = document.querySelector('.desktopmenu');
hamburger.addEventListener('click', () => {
menu.classList.toggle('active');
});
</script>
</body>
</html>
77)Rental WEBPAGE INCOMPLETE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rental Webpage</title>
<link rel="shortcut icon" href="p.jpg" type="image/x-icon">
</head>
<style>
#Nav {
width: 100%;
height: 160px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.nav1 {
width: 100%;
height: 50%;
background-color: white;
border-bottom: 0.5px solid rgba(117, 111, 111, 0.479);
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
box-sizing: border-box;
}
.nav2 {
width: 100%;
height: 50%;
background-color: white;
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
}
.png11 {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 5px;
}
.png11 .png {
width: 25px;
height: 25px;
color: black;
}
.png11 h3 {
font-size: 12px;
color: rgb(56, 56, 56);
font-weight: 300;
}
.logo {
display: flex;
align-items: center;
justify-content: center;
}
.logo h1 {
font-size: 18px;
font-weight: 300;
color: red;
}
.search {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.search input {
width: 250px;
padding: 10px;
font-size: border-box;
border-radius: 30px;
padding-left: 20px;
border: 1px solid rgba(125, 122, 122, 0.416);
font-size: 15px;
color: black;
outline: none;
}
.search button {
padding: 10px;
background-color: red;
color: white;
font-size: 16px;
border-radius: flex;
align-items: center;
justify-content: center;
gap: 5px;
border: none;
transition: all 0.2s;
cursor: pointer;
}
.search button:hover {
border: 2px solid red;
background: transparent;
color: red;
}
.search .png {
width: 20px;
height: 20px;
color: white;
}
.search button:hover .png {
color: red;
}
.ham {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
}
#btn1 {
border: none;
outline: none;
background-color: white;
font-size: 16px;
font-weight: 300;
cursor: pointer;
border-radius: 30px;
padding: 10px 20px 10px 20px;
box-sizing: border-box;
transition: all 0.1s;
}
#btn1:hover {
background-color: rgba(232, 230, 230, 0.844);
}
#btn2 {
border: 1px solid rgba(97, 93, 0.844);
outline: none;
background-color: white;
color: black;
cursor: pointer;
border-radius: 30px;
padding: 10px 20px 10px 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.1s;
}
#png1 {
width: 18px;
height: 18px;
fill: rgba(92, 89, 89, 0.651);
}
#png2 {
width: 25px;
height: 25px;
fill: rgba(92, 89, 89, 0.651);
}
#btn2:hover {
box-shadow: 2px 2px 10px black;
}
.hamburger {
position: absolute;
width: 220px;
height: 230px;
background-color: white;
right: 3%;
top: 45%;
box-shadow: 2px 2px 10px rgb(80, 78, 78);
border-radius: 30px;
display: flex;
align-items: start;
justify-content: center;
flex-direction: column;
padding: 10px;
box-sizing: border-box;
}
.ham1 {
padding: 10px;
box-sizing: border-box;
font-size: 16px;
font-weight: 300;
color: black;
cursor: pointer;
width: 100%;
border-radius: 30px;
}
.ham1:hover {
background-color: rgba(232, 230, 230, 0.844);
}
@media (max-width: 900px) {
#btn1 {
display: none;
}
}
@media (max-width: 800px) {
.logo h1 {
display: none;
}
.Nav1 {
overflow: hidden;
padding: 10px;
}
.nav2 {
overflow-y: hidden;
overflow-x: scroll;
justify-content: start;
padding: 10px;
}
.svg11 {
flex-shrink: 0;
scrollbar-width: none;
}
.search input {
width: 180px;
font-size: 15px;
}
.search button span {
display: none;
}
.search {
gap: 20px;
}
}
@media (min-width: 500px) {
#btn2 {
border: none;
padding: 0;
}
#png2 {
display: none;
}
#png1 {
width: 25px;
height: 25px;
fill: black;
}
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
#Nav {
position: fixed;
top: 0;
z-index: 10;
}
#home {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 30px;
background-color: white;
margin-top: 180px;
}
.card {
width: 300px;
height: 450px;
max-width: 90%;
display: flex;
align-items: start;
flex-direction: column;
justify-content: center;
gap: 5px;
}
.card .images {
width: 100%;
height: 65%;
overflow: scroll;
display: flex;
align-items: center;
justify-content: start;
border-radius: 6px;
}
.images img {
width: 100%;
height: 100%;
flex-shrink: 0;
}
.cardspan1 {
font-size: 20px;
font-weight: 300;
color: rgb(70, 69, 69);
}
</style>
<body>
<div id="Nav">
<div class="hamburger">
<div class="ham1">LOGIN</div>
<div class="ham1">SignUp</div>
<div class="ham1">List Your Home</div>
<div class="ham1">help center</div>
</div>
<div class="nav1">
<div class="logo">
<img src="p.jpg" alt="" width="50px">
<h1>Private property Rental</h1>
</div>
<div class="search">
<input type="text" placeholder="search destination" />
<button>
<img src="search-interface-symbol.png" alt="Search Icon" style="width: 20px; height: 20px;">
<span>Search</span>
</button>
</div>
<div class="ham">
<button id="btn1">List Your Home</button>
<button id="btn2" onClick="setvisible(prev=>!perv)">
<img id="png1" src="hamburger.png" alt="Menu" style="width: 20px; height: 20px;">
<img id="png2" src="user.png" alt="Menu" style="width: 20px; height: 20px;">
</button>
</div>
</div>
<div class="nav2">
<div class="png11">
<a href="/trending">
<img src="/images/trending.png" alt="Trending" />
<h3>Trending</h3>
</a>
</div>
<div class="png11">
<a href="/houses">
<img src="/images/houses.png" alt="Houses" />
<h3>Houses</h3>
</a>
</div>
<div class="png11">
<a href="/rooms">
<img src="/images/rooms.png" alt="Rooms" />
<h3>Rooms</h3>
</a>
</div>
<div class="png11">
<a href="/farmhouses">
<img src="/images/farmhouses.png" alt="Farm Houses" />
<h3>Farm Houses</h3>
</a>
</div>
<div class="png11">
<a href="/poolhouses">
<img src="/images/poolhouses.png" alt="Pool Houses" />
<h3>Pool Houses</h3>
</a>
</div>
<div class="png11">
<a href="/tenthouses">
<img src="/images/tenthouses.png" alt="Tent Houses" />
<h3>Tent Houses</h3>
</a>
</div>
<div class="png11">
<a href="/cabins">
<img src="/images/cabins.png" alt="Cabins" />
<h3>Cabins</h3>
</a>
</div>
<div class="png11">
<a href="/shops">
<img src="/images/shops.png" alt="Shops" />
<h3>Shops</h3>
</a>
</div>
<div class="png11">
<a href="/foresthouses">
<img src="/images/foresthouses.png" alt="Forest Houses" />
<h3>Forest Houses</h3>
</a>
</div>
</div>
<div class="home">
<Card image1="House1" image2="House2" image3="House3" title="3BHK Villa in Mumbai" price="$40,000">
<Card image1="House1" image2="House2" image3="House3" title="3BHK Villa in Mumbai" price="$40,000">
</div>
<div class="card" (image1,image2,image3,title,price)>
<div class="images">
<img src="image1" alt="House 1" />
<img src="image2" alt="House 2" />
<img src="image3" alt="House 3" />
</div>
<span class="cardspan1">(title)</span>
<span class="cardspan2">(price)/Month</span>
</div>
<script>
let [Visible, setvisible] = usestate(false)
const addCardBtn = document.getElementById('addCardBtn');
const homeContainer = document.getElementById('home');
addCardBtn.addEventListener('click', () => {
const image1 = document.getElementById('image1').value;
const image2 = document.getElementById('image2').value;
const image3 = document.getElementById('image3').value;
const title = document.getElementById('title').value;
const price = document.getElementById('price').value;
if (image1 && image2 && image3 && title && price) {
const card = document.createElement('div');
card.classList.add('card');
card.innerHTML = `
<div class="images">
<img src="${image1}" alt="House 1" />
<img src="${image2}" alt="House 2" />
<img src="${image3}" alt="House 3" />
</div>
<span class="cardspan1">${title}</span>
<span class="cardspan2">${price}/Month</span>
`;
homeContainer.appendChild(card);
// Clear the form
document.getElementById('image1').value = '';
document.getElementById('image2').value = '';
document.getElementById('image3').value = '';
document.getElementById('title').value = '';
document.getElementById('price').value = '';
} else {
alert('Please fill out all fields!');
}
});
</script>
</body>
</html>
78)Rental Website API Format
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rental Webpage</title>
<link rel="shortcut icon" href="p.jpg" type="image/x-icon">
<style>
/* Add the styles here as in your previous code */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
header {
background-color: #4CAF50;
color: white;
text-align: center;
padding: 1em;
}
main {
margin: 20px;
}
#form-section,
#display-section {
margin-bottom: 30px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
}
form label {
font-weight: bold;
}
form input,
form button {
padding: 10px;
font-size: 16px;
}
form button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
form button:hover {
background-color: #45a049;
}
/* Card Container and Image Box */
#card-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
margin-bottom: 20px;
}
.card {
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
padding: 15px;
text-align: center;
background: #fff;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 400px; /* Set a fixed height for all cards */
}
.image-box {
flex-grow: 1; /* Allow the image box to fill available space */
display: flex;
justify-content: start;
align-items: center;
height: 200px; /* Set a consistent height for the image section */
overflow-x: scroll; /* Allow horizontal scrolling */
gap: 10px; /* Space between images */
}
.image-box img {
width: 150px; /* Fixed width for images */
height: 100%;
object-fit: cover; /* Ensures images fill the space without distortion */
border-radius: 5px;
cursor: pointer;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
z-index: 1000;
}
.modal img {
max-width: 90%;
max-height: 90%;
margin: auto;
display: block;
}
.modal.active {
display: flex;
}
.modal-close {
position: absolute;
top: 20px;
right: 20px;
background-color: white;
border: none;
font-size: 20px;
cursor: pointer;
}
.card h3 {
font-size: 18px;
margin: 10px 0;
}
.card p {
font-size: 14px;
margin: 5px 0;
}
.sale-btn,
.delete-btn {
margin: 10px 5px;
padding: 10px 15px;
font-size: 14px;
border-radius: 5px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
.sale-btn:hover,
.delete-btn:hover {
background-color: #45a049;
}
/* Responsive Design */
@media screen and (max-width: 600px) {
#card-container {
grid-template-columns: repeat(1, 1fr); /* Stack cards in one column for smaller screens */
}
.card {
height: auto; /* Allow cards to resize for smaller screens */
}
.sale-btn,
.delete-btn {
font-size: 12px;
}
}
</style>
</head>
<body>
<header>
<h1>Rent a House or Villa</h1>
</header>
<main>
<section id="form-section">
<h2>Add a House or Villa</h2>
<form id="rental-form" enctype="multipart/form-data">
<label for="title">Title:</label>
<input type="text" id="title" name="title" required>
<label for="description">Description:</label>
<input id="description" name="description" required></input>
<label for="image1">Image 1:</label>
<input type="file" id="image1" name="image1" accept="image/*" required>
<label for="image2">Image 2:</label>
<input type="file" id="image2" name="image2" accept="image/*" required>
<label for="image3">Image 3:</label>
<input type="file" id="image3" name="image3" accept="image/*" required>
<label for="price">Price:</label>
<input type="number" id="price" name="price" required>
<label for="place">Location:</label>
<input type="text" id="place" name="place" required>
<label for="contact">Mobile Number:</label>
<input type="text" id="contact" name="contact" required>
<button type="submit">Submit</button>
</form>
</section>
<section id="display-section">
<h2>Available Rentals</h2>
<div id="card-container"></div>
</section>
</main>
<!-- Modal for viewing images -->
<div class="modal" id="image-modal">
<button class="modal-close" id="modal-close">X</button>
<img src="" alt="Modal Image" id="modal-img">
</div>
<script>
const form = document.getElementById('rental-form');
const cardContainer = document.getElementById('card-container');
const modal = document.getElementById('image-modal');
const modalImg = document.getElementById('modal-img');
const modalClose = document.getElementById('modal-close');
// Load saved rentals from the server on page load
window.addEventListener('load', () => {
fetch('/api/rentals') // Adjust the URL for your API endpoint
.then(response => response.json())
.then(rentals => {
rentals.forEach((data) => addRentalCard(data, false));
})
.catch(error => console.error('Error fetching rental data:', error));
});
// Form submission to send rental data to the server
form.addEventListener('submit', function (event) {
event.preventDefault();
const title = document.getElementById('title').value;
const description = document.getElementById('description').value;
const image1 = document.getElementById('image1').files[0];
const image2 = document.getElementById('image2').files[0];
const image3 = document.getElementById('image3').files[0];
const price = document.getElementById('price').value;
const place = document.getElementById('place').value;
const contact = document.getElementById('contact').value;
const reader1 = new FileReader();
const reader2 = new FileReader();
const reader3 = new FileReader();
reader1.onload = function (e) {
const img1Url = e.target.result;
reader2.onload = function (e) {
const img2Url = e.target.result;
reader3.onload = function (e) {
const img3Url = e.target.result;
const rentalData = { title, description, price, place, contact, images: [img1Url, img2Url, img3Url], onSale: false };
fetch('/api/rentals', { // Adjust the URL for your API endpoint
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(rentalData),
})
.then(response => response.json())
.then(data => {
addRentalCard(data, true);
})
.catch(error => console.error('Error submitting rental data:', error));
};
reader3.readAsDataURL(image3);
};
reader2.readAsDataURL(image2);
};
reader1.readAsDataURL(image1);
form.reset();
});
function addRentalCard(data, save = true) {
const rentalCard = document.createElement('div');
rentalCard.classList.add('card');
rentalCard.innerHTML = `
<div class="image-box">
${data.images.map(img => `<img src="${img}" alt="Image" onclick="openModal('${img}')">`).join('')}
</div>
<h3>${data.title}</h3>
<p>${data.description}</p>
<p><strong>Price:</strong> $${data.price}</p>
<p><strong>Location:</strong> ${data.place}</p>
<p><strong>Contact:</strong> ${data.contact}</p>
<button class="sale-btn">${data.onSale ? 'Remove from Sale' : 'Mark as On Sale'}</button>
<button class="delete-btn">Delete</button>
`;
rentalCard.querySelector('.sale-btn').addEventListener('click', () => {
data.onSale = !data.onSale;
rentalCard.classList.toggle('on-sale', data.onSale);
rentalCard.querySelector('.sale-btn').textContent = data.onSale ? 'Remove from Sale' : 'Mark as On Sale';
updateRentals();
});
rentalCard.querySelector('.delete-btn').addEventListener('click', () => {
rentalCard.remove();
deleteRental(data);
});
cardContainer.appendChild(rentalCard);
if (save) saveRental(data);
}
// Open image in modal
function openModal(imageSrc) {
modalImg.src = imageSrc;
modal.classList.add('active');
}
// Close modal
modalClose.addEventListener('click', () => {
modal.classList.remove('active');
});
</script>
</body>
</html>
79)Rental webpage through formspree!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rental Webpage</title>
<link rel="shortcut icon" href="p.jpg" type="image/x-icon">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
header {
background-color: #4CAF50;
color: white;
text-align: center;
padding: 1em;
}
main {
margin: 20px;
}
#form-section,
#display-section {
margin-bottom: 30px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
}
form label {
font-weight: bold;
}
form input,
form button {
padding: 10px;
font-size: 16px;
}
form button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
form button:hover {
background-color: #45a049;
}
#card-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
margin-bottom: 20px;
}
.card {
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
padding: 15px;
text-align: center;
background: #fff;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 400px;
}
.image-box {
flex-grow: 1;
display: flex;
justify-content: start;
align-items: center;
height: 200px;
overflow-x: scroll;
gap: 10px;
}
.image-box img {
width: 150px;
height: 100%;
object-fit: cover;
border-radius: 5px;
cursor: pointer;
}
@media screen and (max-width: 600px) {
#card-container {
grid-template-columns: repeat(1, 1fr);
}
.card {
height: auto;
}
}
</style>
</head>
<body>
<header>
<h1>Rent a House or Villa</h1>
</header>
<main>
<section id="form-section">
<h2>Add a House or Villa</h2>
<form id="rental-form" enctype="multipart/form-data" action="// add your forms-pree API here//" method="POST">
<label for="title">Title:</label>
<input type="text" id="title" name="Title" required>
<label for="description">Description:</label>
<input id="description" name="Description" required>
<label for="image1">Image 1:</label>
<input type="file" id="image1" name="Image 1" accept="image/*" required>
<label for="image2">Image 2:</label>
<input type="file" id="image2" name="Image 2" accept="image/*" required>
<label for="image3">Image 3:</label>
<input type="file" id="image3" name="Image 3" accept="image/*" required>
<label for="price">Price:</label>
<input type="number" id="price" name="Price" required>
<label for="place">Location:</label>
<input type="text" id="place" name="Location" required>
<label for="contact">Mobile Number:</label>
<input type="text" id="contact" name="Contact" required>
<label for="email">Email:</label>
<input type="email" id="email" name="Email" required>
<input type="hidden" name="_cc" value="recipient1@example.com,recipient2@example.com">
<button type="submit">Submit</button>
</form>
</section>
<section id="display-section">
<h2>Available Rentals</h2>
<div id="card-container"></div>
</section>
</main>
<script>
document.getElementById('rental-form').addEventListener('submit', function (event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
fetch(form.action, {
method: 'POST',
body: formData,
headers: {
'Accept': 'application/json'
}
}).then(response => {
if (response.ok) {
alert('Form successfully submitted! Emails sent.');
form.reset();
} else {
response.json().then(data => {
const errorMessage = data.error || 'Failed to send emails. Please check your form or try again later.';
alert(errorMessage);
});
}
}).catch(error => {
alert('An error occurred. Please try again.');
console.error(error);
});
});
</script>
</body>
</html>
80)How to add images with our divices with file reader code
html
<form id="image-upload-form">
<label for="image-input">Choose an image:</label>
<input type="file" id="image-input" accept="image/*">
<button type="submit">Upload</button>
</form>
<div id="image-preview-container"></div>
javascript
document.getElementById('image-upload-form').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
const imageInput = document.getElementById('image-input');
const imageFile = imageInput.files[0]; // Get the selected file
if (imageFile) {
const reader = new FileReader();
// When the file is read
reader.onload = function(event) {
const imagePreviewContainer = document.getElementById('image-preview-container');
// Create an image element
const imgElement = document.createElement('img');
imgElement.src = event.target.result; // Set the image source
imgElement.alt = "Uploaded Image";
imgElement.style.width = "200px"; // Set a desired size
imgElement.style.height = "auto";
// Add the image to the container
imagePreviewContainer.innerHTML = ''; // Clear previous images
imagePreviewContainer.appendChild(imgElement);
};
// Read the file as a data URL
reader.readAsDataURL(imageFile);
} else {
alert("Please select an image file.");
}
});
css
#image-preview-container {
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
#image-preview-container img {
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
-----------------------END-------------------------------
0 Comments
if you have any doubts. please let me know