Notes, summaries, assignments, exams, and exercises for Computer science for Secondary education

Fundamental Math Rules: Powers, Roots, and Divisibility

Computer science3.47 KB

Rule of Signs

When performing operations, follow these sign rules:

  • (+) and (+) = +
  • (+) and (-) = -
  • (-) and (-) = +
  • (-) and (+) = -

Calculation of Powers

To calculate a power, multiply the base by itself as many times as indicated by the exponent.

  • 4 raised to 1 = 4
  • 45 raised to 1 = 45
  • -42 = -(4 · 4) = -16
  • 32 = 3 · 3 = 9
  • (-4)3 = (-4) · (-4) · (-4) = -64 (Note: - · - = + and + · - = -)

Operations with Powers

When operations involve the same base, the following rules apply:

  • Multiplication: The exponents are added.
  • Division: The exponents are subtracted.
  • Parentheses: The exponents are multiplied.

Square Roots

To find a square root, we look for a number that, when squared, most closely approximates the root. The base of this power is the result. To compute the...

Continue reading "Fundamental Math Rules: Powers, Roots, and Divisibility" »

How to Install NLTK and Perform Stemming in Python

Computer science2.17 KB

Install NLTK and Perform Stemming

Aim

Install the NLTK toolkit and perform word stemming.

Description

To install NLTK, use pip, Python’s package manager. Run the following command in your terminal:

pip install nltk

Once installed, you can perform stemming using various algorithms available in NLTK. The Porter stemming algorithm is one of the most popular choices.

Stemming is the process of reducing words to their root or base form. NLTK provides several algorithms, including:

  • Porter
  • Lancaster
  • Snowball

In this program, we use the Porter stemming algorithm to process sample text.

Implementation

import nltk
from nltk.stem import PorterStemmer

# Download NLTK resources if not already downloaded
nltk.download('punkt')

def perform_stemming(text):
    """
...
Continue reading "How to Install NLTK and Perform Stemming in Python" »

Professional Web Layouts and Modern Design Components

Computer science949 bytes

Main Title Section

Secondary Subtitle

Jhvyftubnhybutfvubhjytcvbuhvfycvgkjhvbfx cjgh jvhubuh vbyvby vbuygb hbvhb uv.

Danger Action

Main Title Section

Secondary Subtitle

Jhvyftubnhybutfvubhjytcvbuhvfycvgkjhvbfx cjgh jvhubuh vbyvby vbuygb hbvhb uv.

Danger Action

Hydibfugybsyufbesuy

Main Title Section

Secondary Subtitle

Jhvyftubnhybutfvubhjytcvbuhvfycvgkjhvbfx cjgh jvhubuh vbyvby vbuygb hbvhb uv.

Danger Action

Hqhwvxsvxjvjjkkwqhdyhdighvehdbevdbnmwdbmwbdnvwdvndmdmmdjwdjwmd.

Hqhwvxsvxjvjjkkwqhdyhdighvehdbevdbnmwdbmwbdnvwdvndmdmmdjwdjwmd.

© 2021 Company, Inc.

Java Methods for Writing and Reading Image Files in BSQ Format

Computer science2.51 KB

Java Methods for Writing and Reading Image Files

The following two methods handle the header file (.cabecera) of an image, which describes the image and points to its associated data file (.dat).

Method escribirArchivo

This method writes the header file for an Imagen object and then calls escribirBSQ to write the image data.

public static void escribirArchivo(String nombreArchivo, Imagen imagen) throws IOException {
    File f = new File(nombreArchivo);
    FileWriter fr = new FileWriter(f);
    PrintWriter pr = new PrintWriter(fr);
    String nombre = f.getName();
    nombre = nombre.replace(".cabecera", ".dat");
    pr.write(nombre + "\r\n");
    pr.write(imagen.getFormatoImagen() + "\r\n");
    pr.write(imagen.getNumeroBandas() + "\r\n");
...
Continue reading "Java Methods for Writing and Reading Image Files in BSQ Format" »

Java Vehicle Management Program: Cars, Trucks and Buses

Computer science2.65 KB

Java Vehicle Management Program

The following Java code reads input from the console to manage a fleet of vehicles, including cars, trucks, and buses.

Source Code

import java.util.Scanner;

public class Automoviles {
    public static void main(String[] args) {
        try {
            Scanner entrada = new Scanner(System.in);
            String linea;

            // Reading the maximum number of vehicles
            System.out.println("Insert maximum");
            int max;
            linea = entrada.nextLine();
            max = Integer.parseInt(linea);

            // Reading options
            System.out.println("1 -> Car; 2 -> Truck; 3 -> Bus; 4 -> All");
            linea = entrada.nextLine();
            int op = Integer.
...
Continue reading "Java Vehicle Management Program: Cars, Trucks and Buses" »

C Image Processing with OpenCV: Splitting and Inverting Image Quadrants

Computer science6.13 KB

C Image Processing with OpenCV: Splitting and Inverting Image Quadrants

#include <stdio.h>
#include <stdlib.h>

#include <opencv/cv.h>
#include <opencv/highgui.h>

/* 1 Imagen ______2 */
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Error: Usage %s image_file_name\n", argv[0]);
return EXIT_FAILURE;
}
///////////////////////////////////////////////////////////////////////////////
IplImage* Img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
///////////////////////////////////////////////////////////////////////////////
if (!Img) {
printf("Error: file %s not found\n", argv[1]);
return EXIT_FAILURE;
}
////////////////////////////////////////////////////////////////////////
...
Continue reading "C Image Processing with OpenCV: Splitting and Inverting Image Quadrants" »

Photoshop Tools, Shortcuts and Layers: Complete Korean Reference

Computer science8.25 KB

Selection Tools

Rectangular marquee tool: 직사각형 모양으로 선택영역을 만들어준다.

Lasso tool: 일정한 영역을 선택하게 도와주는 도구.

Lasso tool: 자유롭게 영역을 선택한다. 마우스를 떼면 자동으로 시작과 끝을 잇는다.

Polygonal lasso tool: 포인트 별로 이어서 영역을 선택한다. 더블클릭하면 자동완성된다.

Magnetic lasso tool: 주위 모양을 자동으로 인식해서 영역을 선택한다. 정확도는 낮다.

Magic wand: Quick selection tool의 subtool로 tolerance 범위 내의 비슷한 pixel을 선택한다.

Painting and Retouching Tools

Eyedropper tool (Alt+click): 원하는 색을 추출한다.

Spot healing brush: 브러시의 색칠 영역을 많은 부분을...

Continue reading "Photoshop Tools, Shortcuts and Layers: Complete Korean Reference" »

Doubly Linked List in C: Fixed Implementation and Code Review

Computer science7.14 KB

Doubly Linked List (LDE) in C

This document contains the implementation of a doubly linked list (LDE) in C, with functions for allocation, insertion, removal, traversal, and modification of elements.

Header and Includes

#include "LDE.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

Displaying the List in Reverse Order

The function mostra_invertido displays the list from the last element to the first. It first advances to the tail, then prints each element while moving backward.

void mostra_invertido(LDE l, void (*mostra)(void*)) {
    if (lista_vazia(l)) {
        printf("A lista está vazia\n");
    } else {
        ElementoDuplo *p = l.cabeca;
        printf("Dados da lista invertida:\n");
        printf("\n");
...
Continue reading "Doubly Linked List in C: Fixed Implementation and Code Review" »

Como Criar uma Calculadora em JavaScript com Atalhos

Computer science3.88 KB

Implementação de Calculadora em JavaScript

Abaixo está o código fonte completo e corrigido para o funcionamento de uma calculadora web utilizando JavaScript, incluindo suporte para eventos de teclado e operações matemáticas básicas.

Listener para Teclas do Teclado

Este trecho monitora as teclas pressionadas pelo usuário, mapeando números e operadores para as funções correspondentes da calculadora.

document.addEventListener('DOMContentLoaded', function(){
	document.addEventListener('keypress', function(e){
		if (e.which == 48){ inserirNumConsole('0'); }
		else if (e.which == 49){ inserirNumConsole('1'); }
		else if (e.which == 50){ inserirNumConsole('2'); }
		else if (e.which == 51){ inserirNumConsole('3'); }
		else if (e.which == 52)
...
Continue reading "Como Criar uma Calculadora em JavaScript com Atalhos" »

MySQL and SQL Server Cheat Sheet: Backups, Database Creation, Stored Procedures and Views

Computer science3.89 KB

Exporting Data to a File

Use SELECT ... INTO OUTFILE to export query results to a text file:

SELECT nombre, ciudad
INTO OUTFILE 'copia.txt'
FIELDS TERMINATED BY 'l'
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM equipos
WHERE zona = 'oeste';

Database Backups with mysqldump

Backing Up a Single Database

Include drop table statements and lock tables during the dump:

mysqldump --add-drop-table --lock-tables --databases --user=root --password empresa > empresa.sql

Or, without the extra options:

mysqldump -u root -p empresa > empresa.sql

Backing Up Multiple Databases

mysqldump -u root -p --databases empresa jardineria > copia.sql

Backing Up All Databases

mysqldump -u root -p --all-databases > copia.sql

Backing Up Tables

To back up a single...

Continue reading "MySQL and SQL Server Cheat Sheet: Backups, Database Creation, Stored Procedures and Views" »