Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

html codes

The document outlines a Computer Science Survey Form designed to collect user information, including name, email, age, current role, and preferences regarding computer science. It includes various input types such as text fields, dropdowns, radio buttons, and checkboxes for user feedback. Additionally, it features a styling section with CSS for layout and design, as well as JavaScript functions for user management and statistical calculations.

Uploaded by

Joseph Nketia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

html codes

The document outlines a Computer Science Survey Form designed to collect user information, including name, email, age, current role, and preferences regarding computer science. It includes various input types such as text fields, dropdowns, radio buttons, and checkboxes for user feedback. Additionally, it features a styling section with CSS for layout and design, as well as JavaScript functions for user management and statistical calculations.

Uploaded by

Joseph Nketia
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, in
itial-scale=1.0" />
<title>Computer Science Survey Form</title>
<link href="styles.css" rel="stylesheet"/>
</head>
<body>
<h1 id="title">Computer Science Survey Form</h1>
<p id="description">Thank you for finding time to fil
l this form</p>
<form id="survey-form">
<fieldset>
<label id="name-label" for="name">Name</label>
<input
id="name"
type="text"
required
class="formcontrol"
placeholder="Enter your name"
/>
<label id="email-label" for="email">Email</label>
<input
id="email"
type="email"
required
class="formcontrol"
placeholder="Enter your email"
/>
<label id="number-label" for="age">Age(optional)</
label>
<input
id="number"
type="number"
required
class="formcontrol"
min="16"
max="99"
placeholder="Age"
/>
</fieldset>
<fieldset>
<label for="dropdown">Which option best describes
your current role? </label>
<select id="dropdown" name="dropdown" class="
formcontrol">
<option value="">(Select current role)</
option>
<option value="1">Beginner</option>
<option value="2">Intermmediate</option>
<option value="3">Expert</option>
</select>
</fieldset>
<fieldset>
<p> Would you recommend computer science to a fri
end?<p>
<label>
<input
name="recommend"
value="definitely"
type="radio"
class="inline"
checked
/> Definitely</label>
<label>
<input
name="recommend"
value="maybe"
type="radio"
class="inline"
/> Maybe</label>
<label>
<input
name="recommend"
value="not-sure"
type="radio"
class="inline"

/> Not sure</label>


<label for="dropdown">What is your favorite major in Co
mputer Science?</label>
<select id="dropdown" name="dropdown" class="
formcontrol">
<option value="">(Select option)</option>
<option value="1">AI</option>
<option value="2">Cybersecurity</option>
<option value="3">Data Science</option>
</select>

<p> What would you like to see improved<p>


<label>
<input
name="improved"
value="city-meetups"
type="checkbox"
class="inline"

/> City meetups</label>


<label>
<input
name="improved"
value="Videos"
type="checkbox"
class="inline"
/> Videos</label>
<label>
<input
name="improved"
value="data-visualization"
type="checkbox"
class="inline"

/> Data Visualization</label>

</fieldset>
<fieldset>
<p>Any comments or suggestions?</p>
<textarea
id="comments"
class="input-textarea"
name="comment"
placeholder="Enter your comment here..."
></textarea>
</fieldset>
<input id="submit" type="submit" value="Submit" c
lass="submit-button" />
</form>

</body>
</html>
@import url('https://fonts.googleapis.com/css?
family=Poppins:200i,400&display=swap');

body, html {
min-height : 100%;
}

body {
background-image: url(https://images5.content-hci.com/
commimg/myhotcourses/blog/post/myhc_89683.jpg);
font-family: 'Poppins', sans-serif;
font-size: 1rem;
font-weight: 400;
width: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
padding: 20px;
margin: 0;

h1, p {
margin: 1em auto;
text-align: center;
}

form {
width: 100%;
margin: 0 auto;
max-width: 500px;
padding: 20px;
background-color: rgba(27, 27, 50, 0.8);

}
fieldset {
border: none;
padding: 2rem 0;
}
label{
display: flex;
align-items: center;
font-size: 1.125rem;
margin-bottom: 0.5rem;
}
.inline {
display: inline-block;
margin-right: 0.625rem;
min-height: 1.25rem;
min-width: 1.25rem;
}
.formcontrol {
display: block;
width: 100%;
height: 2.375rem;
padding: 0.375rem 0.75rem;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow
0.15s ease-in-out;
}
.form-control:focus {
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.input-textarea {
min-height: 120px;
width: 100%;
padding: 0.625rem;
resize: vertical;
}
.submit-button {
display: block;
width: 100%;
padding: 0.75rem;
background-COLOR:#37af65; ;
color:white;
border-radius: 2px;
cursor: pointer;
}
input,
button,
select,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
<table>
<thead>
<th>Name</th>
<th>Age</th>
<th>Program</th>
<th>Level</th>
</thead>
<tbody>
<tr>
<td>Priscilla Obeng</td>
<td>20</td>
<td>Computer Science</td>
<td>300</td>
</tr>
</tbody>
</table>

table{
border: 2px solid pink;
border-collapse: collapse ;
}
td , th{
border: 2px solid red;
padding: 5px;
}
function signUp(newUser) {

const existingUser = users.find(user => user.email === newUser.email);

if (existingUser) {

console.log('User already exists.');

return;

users.push(newUser);

console.log('User added successfully.');

// Example usage:

const newUser = {

_id: 'iuytfd',

username: 'John',

email: 'john@example.com',

password: '789789',

createdAt: '08/01/2020 10:30 AM',

isLoggedIn: false

};

signUp(newUser);

The signUp function takes a newUser object as a parameter. It checks if the user already exists in the
users array by comparing the email property. If the user exists, it logs a message informing the user.
Otherwise, it adds the newUser object to the users array and logs a success message.

Note: In this implementation, the users array is mutable, meaning it will be modified directly.
const statistics = {

sample: [],

setSample: function (sample) {

if (Array.isArray(sample)) {

this.sample = sample;

} else {

console.log("Invalid sample. Please provide an array.");

},

mean: function () {

if (this.sample.length === 0) {

return null;

const sum = this.sample.reduce((acc, num) => acc + num, 0);

return sum / this.sample.length;

},

median: function () {

if (this.sample.length === 0) {

return null;

}
const sortedSample = this.sample.slice().sort((a, b) => a - b);

const middleIndex = Math.floor(sortedSample.length / 2);

if (sortedSample.length % 2 === 0) {

return (sortedSample[middleIndex - 1] + sortedSample[middleIndex]) / 2;

} else {

return sortedSample[middleIndex];

},

mode: function () {

if (this.sample.length === 0) {

return null;

const frequencyMap = {};

let maxFrequency = 0;

let modes = [];

for (let num of this.sample) {

frequencyMap[num] = (frequencyMap[num] || 0) + 1;

if (frequencyMap[num] > maxFrequency) {

maxFrequency = frequencyMap[num];

for (let num in frequencyMap) {

if (frequencyMap[num] === maxFrequency) {

modes.push(parseFloat(num));

}
return modes.length === this.sample.length ? null : modes;

},

range: function () {

if (this.sample.length === 0) {

return null;

const sortedSample = this.sample.slice().sort((a, b) => a - b);

return sortedSample[sortedSample.length - 1] - sortedSample[0];

},

variance: function () {

if (this.sample.length === 0) {

return null;

const mean = this.mean();

const squaredDifferences = this.sample.map((num) => (num - mean) ** 2);

const sumOfSquaredDifferences = squaredDifferences.reduce(

(acc, num) => acc + num,

);

return sumOfSquaredDifferences / this.sample.length;

},

standardDeviation: function () {

if (this.sample.length === 0) {

return null;

}
return Math.sqrt(this.variance());

},

min: function () {

if (this.sample.length === 0) {

return null;

return Math.min(...this.sample);

},

max: function () {

if (this.sample.length === 0) {

return null;

return Math.max(...this.sample);

},

count: function () {

return this.sample.length;

},

percentile: function (percent) {

if (this.sample.length === 0) {

return null;

const sortedSample = this.sample.slice().sort((a, b) => a - b);

const index = (percent / 100) * (sortedSample.length - 1);

const lowerValue = Math.floor(index);

const upperValue = Math.ceil(index);


if (lowerValue === upperValue) {

return sortedSample[lowerValue];

} else {

const interpolation =

sortedSample[lowerValue] +

(index - lowerValue) *

(sortedSample[upperValue] - sortedSample[lowerValue]);

return interpolation;

},

frequencyDistribution: function () {

if (this.sample.length === 0) {

return null;

const frequencyMap = {};

for (let num of this.sample) {

frequencyMap[num] = (frequencyMap[num] || 0) + 1;

return frequencyMap;

},

};

// Example usage

statistics.setSample([5, 1, 3, 2, 4, 5, 2, 1, 3, 4, 5]);

console.log("Sample:", statistics.sample);

console.log("Mean:", statistics.mean());

console.log("Median:", statistics.median());

console.log("Mode:", statistics.mode());
console.log("Range:", statistics.range());

console.log("Variance:", statistics.variance());

console.log("Standard Deviation:", statistics.standardDeviation());

console.log("Min:", statistics.min());

console.log("Max:", statistics.max());

console.log("Count:", statistics.count());

console.log("Percentile (25%):", statistics.percentile(25));

console.log("Frequency Distribution:", statistics.frequencyDistribution());


const countries = [

name: 'Afghanistan',

capital: 'Kabul',

languages: ['Pashto', 'Uzbek', 'Turkmen'],

population: 27657145,

flag: 'https://restcountries.eu/data/afg.svg',

currency: 'Afghan afghani'

},

// ... Rest of the countries

];

const uniqueLanguages = new Set();

countries.forEach(country => {

country.languages.forEach(language => {

uniqueLanguages.add(language);

});

});

const numLanguages = uniqueLanguages.size;

console.log(numLanguages);
function convertArrayToObject(students) {

const convertedArray = [];

for (const student of students) {

const [name, skills, scores] = student;

const studentObj = {

name: name,

skills: skills,

scores: scores

};

convertedArray.push(studentObj);

return convertedArray;

const students = [

['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]],

['John', ['HTM', 'CSS', 'JS', 'React'], [85, 80, 85, 80]]

];

console.log(convertArrayToObject(students));
const catsAPI = 'https://api.thecatapi.com/v1/breeds';

fetch(catsAPI)

.then(response => response.json())

.then(data => {

const weights = data.map(cat => cat.weight.metric.split(' - '));

const averageWeight = calculateAverageWeight(weights);

console.log(`The average weight of cats in metric units is: ${averageWeight} kg`);

})

.catch(error => console.log('Error:', error));

function calculateAverageWeight(weights) {

const totalWeight = weights.reduce((sum, weight) => {

const minWeight = parseFloat(weight[0]);

const maxWeight = parseFloat(weight[1]);

return sum + ((minWeight + maxWeight) / 2);

}, 0);

const averageWeight = totalWeight / weights.length;

return averageWeight.toFixed(2);

}
const countriesAPI = 'https://restcountries.com/v2/all';

fetch(countriesAPI)

.then(response => response.json())

.then(data => {

const sortedCountries = data.sort((a, b) => b.population - a.population);

const top10Countries = sortedCountries.slice(0, 10);

console.log('Top 10 countries by population:');

top10Countries.forEach((country, index) => {

console.log(`${index + 1}. ${country.name} - ${country.population}`);

});

})

.catch(error => console.log('Error:', error));


function outerFunction() {

let count = 0;

function plusOne() {

count++

return count

function minusOne() {

count--

return count

return {

plusOne:plusOne(),

minusOne:minusOne()

const innerFuncs = outerFunction()

console.log(innerFuncs.plusOne)

console.log(innerFuncs.minusOne)
Creating a Twitter bot that tweets Chelsea news is a great idea! Here are some additional special
features you can consider adding to enhance your bot's functionality:

1. Real-time updates: Ensure that your bot fetches the latest Chelsea news from reliable sources in real-
time. This can be accomplished by using news APIs or scraping websites that provide up-to-date
information on Chelsea.

2. Content filtering: Implement a content filtering mechanism to ensure that your bot only tweets news
that is relevant and reliable. You can use keywords, trusted sources, or sentiment analysis to filter out
irrelevant or potentially false news.

3. Personalization: Allow users to customize the bot's behavior to some extent. For example, users may
choose to receive news about specific players, match updates, transfer rumors, or other Chelsea-related
topics. This personalization can be done through direct messages or by using specific hashtags in replies
to the bot.

4. Engage with followers: Make your bot more interactive by responding to mentions, retweets, or
direct messages from followers. You can set up automated replies to specific keywords or even include
features like trivia quizzes or polls related to Chelsea.

5. Multimedia content: Don't limit your bot to just text-based tweets. Enhance the user experience by
occasionally including images, videos, or GIFs related to the news you're sharing. This could involve
highlights from matches, player interviews, or behind-the-scenes footage.

6. Scheduled tweets: To ensure consistent activity, consider implementing a scheduling feature that
allows your bot to automatically tweet at specific times of the day or before/after matches. This will
help keep your followers engaged and up to date.

7. Trending topics: Keep an eye on Twitter's trending topics and incorporate them into your bot's tweets
when relevant. This could involve mentioning Chelsea players involved in trending discussions or
providing insights related to current football trends.
8. Notification service: Offer users the option to receive notifications for important Chelsea news or
updates. This can be achieved by implementing a subscription feature where users can opt-in to receive
direct messages or push notifications whenever significant news breaks.

Remember to adhere to Twitter's developer guidelines and terms of service while developing your bot.
Also, be mindful of copyright issues when using content from external sources.

import openai

import feedparser

import tweepy

import random

import time

import mclachbot as mbot

import matplotlib.pyplot as plt

# RSS feed URLs

feed_urls = [

"https://www.chelseafc.com/en/rss.xml",

"https://weaintgotnohistory.sbnation.com/rss/current",

"https://talkchelsea.net/feed/",

# OpenAI API credentials

openai.api_key = "YOUR_API_KEY_HERE"

# Twitter API credentials

consumer_key = "YOUR_CONSUMER_KEY_HERE"

consumer_secret = "YOUR_CONSUMER_SECRET_HERE"

access_token = "YOUR_ACCESS_TOKEN_HERE"

access_token_secret = "YOUR_ACCESS_TOKEN_SECRET_HERE"
# GPT-3 model ID and prompt

model_id = "davinci"

prompt = "Summarize the following text:"

# Authenticate with Twitter API

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

# Shuffle the feed URLs to randomize the order in which they are processed

random.shuffle(feed_urls)

# Custom function to generate statistics and visualizations

def generate_statistics(full_text):

# Use mclachbot to generate statistical data

statistics = mbot.generate_statistics(full_text)

# Plot the generated data as a visualization

plt.plot(statistics)

plt.xlabel('X-axis label')

plt.ylabel('Y-axis label')

plt.title('Data Visualization')

plt.savefig('visualization.png') # Save the visualization as an image

return statistics

# Process each feed URL

for feed_url in feed_urls:


# Parse the RSS feed

feed = feedparser.parse(feed_url)

# Iterate over the entries in reverse order (oldest to newest)

for entry in reversed(feed.entries):

# Extract the full text of the entry

full_text = entry.get("content")[0].get("value")

# Call the OpenAI GPT-3 API to summarize the text

response = openai.Completion.create(

engine=model_id,

prompt=f"{prompt}\n{full_text}",

max_tokens=60,

n=1,

stop=None,

temperature=0.5,

# Extract the generated summary

summary = response.choices[0].text.strip()

# Prepare the tweet content

tweet_content = f"{summary}\n\n{entry.link}\n\nAttribution: {entry.title}"

# Generate statistics and visualization

statistics = generate_statistics(full_text)

# Attach the visualization image to the tweet

media = api.media_upload('visualization.png')
api.update_status(status=tweet_content, media_ids=[media.media_id])

# Print confirmation

print("Tweet posted successfully!")

# Add a delay between tweets to comply with Twitter rate limits

time.sleep(5)

# Select a specific entry to create a separate tweet with statistics and visualization

separate_entry = feed.entries[0] # Choose a different entry or modify as per your preference

separate_full_text = separate_entry.get("content")[0].get("value")

# Generate statistics and visualization for the separate tweet

separate_statistics = generate_statistics(separate_full_text)

# Prepare the separate tweet content with statistics and visualization

separate_tweet_content = "Check out these statistics and visualization!\n\n" + \

"Statistical data: " + str(separate_statistics) + "\n\n" + \

"Attribution: " + separate_entry.title

# Attach the visualization image to the separate tweet

media = api.media_upload('visualization.png')

api.update_status(status=separate_tweet_content, media_ids=[media.media_id])

# Print confirmation

print("Separate tweet posted successfully!")

# Add a delay between separate tweets to comply with Twitter rate limits

time.sleep(5)
api_key = 'Mxb2NOI4gBUvpieozHPkfizd5'

api_secret = "edL0yyhBUCt7rfnAmuZmN3R8B1SlepTc8iQ8EpsFbWE09SkkTc"

bearer_token = 'AAAAAAAAAAAAAAAAAAAAACbUngEAAAAAqRJUaSCOscKO0fAaVcpT50nTSvk
%3DAgMPUWbdGNe8xYXS3Og2tnT2WCw0gmQpaqsNJkAl3vlQGfk53b'

access_token = "1660934714457223170-NcZmTCQIyb4IvMRctkJjIS3OSLLb6z"

access_token_secret = "RWBaWhjXmG2PL00Vs2skDjJKTchrpF7IiWazOmbZHzGkI"

You might also like