Welcome to my blog dedicated to providing study materials and learning resources for computer science. My goal is to make computer science accessible and approachable for everyone.
As an individual creator, I have carefully curated a collection of study materials and learning resources that cover a wide range of computer science topics. Whether you are a beginner or an advanced learner, I have something for everyone.
My blog includes articles, tutorials, that cover topics such as programming languages, data structures, algorithms, web development, and more. My content is designed to be easy to understand and to help you build a solid foundation in computer science.
I believe that everyone should have access to quality education, which is why my blog is completely free. I am passionate about empowering people with the knowledge and skills they need to succeed in today's technology driven world.
Thank you for visiting my blog. I hope that you find my study materials and learning resources helpful. If you have any questions or feedback, please don't hesitate to contact me at comment section or on my Facebook page.
#include
ReplyDelete#include
#include
#include
void main(){
int gd=DETECT,gm;
int x1,y1,x2,y2,x3,y3,ref;
clrscr();
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
printf("\nEnter The Co-ordinates of triangle:\n");
scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
line(320,0,320,460);
line(0,230,640,230);
printf("\nenter 1 for rotating about x-axis & 2 for rotating about y-axis:\n");
scanf("%d",&ref);
if (ref==1){
if(y1>230){
x1=x1;
x2=x2;
x3=x3;
y1=y1-230;
y2=y2-230;
y3=y3-230;
}
else
{
x1=x1;
x2=x2;
x3=x3;
y1=y1+230;
y2=y2+230;
y3=y3+230;
}
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
}
if (ref==2){
if (x1>320){
x1=x1;
x2=x2;
x3=x3;
y1=y1-320;
y2=y2-320;
y3=y3-320;
}
else{
x1=x1;
x2=x2;
x3=x3;
y1=y1+320;
y2=y2+320;
y3=y3+320;}
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x1,y1,x3,y3);
}
printf("\ntriangle after reflection");
getch();
}
from Crypto.PublicKey import RSA
ReplyDeletefrom Crypto.Cipher import PKCS1_OAEP
import binascii
keyPair = RSA.generate(2048)
pubKey = keyPair.publickey()
privKey = keyPair
print(f"Public key: (n = {hex(pubKey.n)}, e = {hex(pubKey.e)})")
pubKeyPEM = pubKey.exportKey()
print(pubKeyPEM.decode('ascii'))
print(f"Private key: (n = {hex(pubKey.n)}, d = {hex(keyPair.d)})")
privKeyPEM = keyPair.exportKey()
print(privKeyPEM.decode('ascii'))
msg = 'Hello, World!'
encryptor = PKCS1_OAEP.new(pubKey)
encrypted = encryptor.encrypt(msg.encode('utf-8'))
print("Encrypted:", binascii.hexlify(encrypted))
decryptor = PKCS1_OAEP.new(privKey)
decrypted = decryptor.decrypt(encrypted)
print("Decrypted:", decrypted.decode('utf-8'))
using System;
ReplyDeleteusing System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace GPPractical
{
public partial class Form1 : Form
{
Microsoft.DirectX.Direct3D.Device device;
public Form1()
{
InitializeComponent();
initDevice();
}
public void InitDevice() {
PresentParameterspp = new PresentParameters();
GPPractical.Windowed = true;
GPPractical.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType, Hardware, this, CreateFlags, HardwareVertexProcessing, pp);
}
private void Render()
{
device.Clear(ClearFlags, TargetColor, Orange, 0, 1);
device.Present();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_paint(object sender, PaintEventArgs e)
{
Render();
}
}
}
using System;
ReplyDeleteusing System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace GP_Prac_1
{
public partial class Form1 : Form
{
Microsoft.DirectX.Direct3D.Device device;
public Form1()
{
InitializeComponent();
InitDevice();
}
public void InitDevice()
{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing,pp);
}
private void Render() {
device.Clear(ClearFlags.Target, Color.Red, 0, 1);
device.Present();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Render();
}
}
}
using System;
ReplyDeleteusingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingMicrosoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace GP_P2
{
public partial class Form1 : Form
{
Microsoft.DirectX.Direct3D.Device device;
public Form1()
{
InitializeComponent();
InitDevice();
}
private void InitDevice()
{
PresentParameterspp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.HardwareVertexProcessing, pp);
}
private void Render()
{
CustomVertex.TransformedColored[] vertexes = new
CustomVertex.TransformedColored[3];
vertexes[0].Position = new Vector4(240, 110, 0, 1.0f);//first point
vertexes[0].Color = System.Drawing.Color.FromArgb(0, 255, 0).ToArgb();
vertexes[1].Position = new Vector4(380, 420, 0, 1.0f);//second point
vertexes[1].Color = System.Drawing.Color.FromArgb(0, 0, 255).ToArgb();
vertexes[2].Position = new Vector4(110, 420, 0, 1.0f);//third point
vertexes[2].Color = System.Drawing.Color.FromArgb(255, 0, 0).ToArgb();
device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
device.BeginScene();
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertexes);
device.EndScene();
device.Present();
}
private void Form1_Load(object sender, EventArgs e) { }
private void Form1_Paint(object sender, PaintEventArgs e)
{
Render();
}
}
}
2nd triangle with color:
ReplyDeleteusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace p3
{
public partial class Form1 : Form
{
Microsoft.DirectX.Direct3D.Device device;
public Form1()
{
InitializeComponent();
InitDevice();
}
private void InitDevice()
{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.HardwareVertexProcessing, pp);
}
private void Render()
{
CustomVertex.TransformedColored[] vertexes = new
CustomVertex.TransformedColored[3];
vertexes[0].Position = new Vector4(240, 110, 0, 1.0f);//first point
vertexes[0].Color = System.Drawing.Color.FromArgb(0, 255, 0).ToArgb();
vertexes[1].Position = new Vector4(380, 420, 0, 1.0f);//second point
vertexes[1].Color = System.Drawing.Color.FromArgb( 255,0,255).ToArgb();
vertexes[2].Position = new Vector4(110, 420, 0, 1.0f);//third point
vertexes[2].Color = System.Drawing.Color.FromArgb(255, 0, 0).ToArgb();
device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0);
device.BeginScene();
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertexes);
device.EndScene();
device.Present();
}
private void Form1_Load(object sender, EventArgs e) { }
private void Form1_Paint(object sender, PaintEventArgs e)
{
Render();
}
}
}
p3: triangle with image
ReplyDeleteusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace p3
{
public partial class Form1 : Form
{
private Microsoft.DirectX.Direct3D.Device device;
private CustomVertex.PositionTextured[] vertex = new CustomVertex.PositionTextured[3];
private Texture texture;
public Form1()
{
InitializeComponent();
InitDevice();
}
private void InitDevice()
{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0,DeviceType .Hardware ,this, CreateFlags.HardwareVertexProcessing, pp);
device.Transform.Projection = Matrix.PerspectiveFovLH(3.14f / 4, device.Viewport.Width / device.Viewport.Height, 1f, 1000f);
device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, 20), new Vector3(),
new Vector3(0, 1, 0));
device.RenderState.Lighting = false;
vertex[0] = new CustomVertex.PositionTextured(new Vector3(0, 0, 0), 0, 0);
vertex[1] = new CustomVertex.PositionTextured(new Vector3(5, 0, 0), 0, 1);
vertex[2] = new CustomVertex.PositionTextured(new Vector3(0, 5, 0),-1, 1);
texture=new Texture (device,new Bitmap ("C:\\Users\\PC350\\Pictures\\Screenshots\\img.png"), 0,
Pool.Managed);
}
private void Form1_Load(Object sender, EventArgs e)
{ }
private void Form1_Paint(Object sender, PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1, 0);
device.BeginScene();
device.SetTexture(0,texture);
device.VertexFormat = CustomVertex.PositionTextured.Format;
device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex);
device.EndScene();
device.Present();
}
}
}
ReplyDeleteimport numpy as np
import pandas as pd
from typing import List, Dict
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import streamlit as st
# Load dataset
songs = pd.read_csv(r'F:\newmL\songdata.csv')
songs = songs.sample(n=5000).drop('link', axis=1).reset_index(drop=True)
songs['text'] = songs['text'].str.replace(r'\n', '', regex=True)
# Create TF-IDF matrix and compute cosine similarity
tfidf = TfidfVectorizer(analyzer='word', stop_words='english')
lyrics_matrix = tfidf.fit_transform(songs['text'])
cosine_similarities = cosine_similarity(lyrics_matrix)
# Prepare similarities dictionary
similarities = {}
for i in range(len(cosine_similarities)):
similar_indices = cosine_similarities[i].argsort()[:-50:-1]
similarities[songs['song'].iloc[i]] = [(cosine_similarities[i][x], songs['song'][x], songs['artist'][x]) for x in similar_indices][1:]
class ContentBasedRecommender:
def __init__(self, matrix):
self.matrix_similar = matrix
def recommend(self, song, number_songs):
return self.matrix_similar.get(song, [])[:number_songs]
# Streamlit UI
st.title("Music Recommendation System")
# User input for song title and number of recommendations
selected_song = st.selectbox("Select a song:", songs['song'].tolist())
number_of_songs = st.number_input("Number of recommendations:", min_value=1, max_value=10, value=4)
if st.button("Get Recommendations"):
recommender = ContentBasedRecommender(similarities)
recommendations = recommender.recommend(selected_song, number_of_songs)
if recommendations:
st.subheader(f"Recommendations for '{selected_song}':")
for idx, (score, song_name, artist_name) in enumerate(recommendations):
st.write(f"{idx + 1}. **{song_name}** by **{artist_name}** (Similarity Score: {round(score, 3)})")
else:
st.write("No recommendations found.")