Skip to content

Instantly share code, notes, and snippets.

View paulodutra's full-sized avatar

Paulo Dutra paulodutra

View GitHub Profile
@paulodutra
paulodutra / for-range.py
Created July 25, 2023 13:20
An example using for and range
for i in range(1,3):
print(i)
@paulodutra
paulodutra / count-logic.py
Created July 25, 2023 13:22
An example using count
sum = 0
count = 0
for c in range(1,7):
num = int(input('Digite o {} valor: '.format(c)))
if num % 2 == 0:
sum = sum + num
count = count + 1
print('Você informou {} números PARES e a soma foi {}'.format(count, sum))
@paulodutra
paulodutra / count-logic-example2.py
Created July 25, 2023 13:24
Second example using count logic
count = 0
for c in range(1,7):
letter = str(input('Digite a primeira {} vogal: '.format(c)))
if letter == 'A' or letter == 'a':
count = count + 1
print('Você informou a vogal A {} vezes'.format(count))
@paulodutra
paulodutra / random-number.py
Created July 29, 2023 15:45
An example using python for hit random number.
import random
tentativas = 0
palpite = False
numSorteado = random.randint(1,10)
while (palpite is False):
num = int(input('Digite um numero: '))
if num != numSorteado:
tentativas = tentativas + 1
else:
@paulodutra
paulodutra / validate-genre.py
Created July 29, 2023 15:57
An example using python to receive the genre of person and validate it.
validacao = False
while (validacao is False):
sexo = str(input('Informe o seu sexo, sendo M - Masculino e F- Feminimo: '))
if sexo == 'M' or sexo == 'm' or sexo == 'F' or sexo == 'f':
validacao = True
else:
validacao = False
@paulodutra
paulodutra / Button.tsx
Last active August 17, 2023 18:52
Three examples of buttons components using type for props without React.PropsWithChildren
import React, { ReactNode } from 'react'
type ButtonProps = {
lenghtButton?: string;
children: ReactNode;
onClick?: () => void
};
export const Button = (props: ButtonProps) => {
return (
<button onClick={props.onClick} style={{fontSize: props.lenghtButton}}>
@paulodutra
paulodutra / Button-ReactNode.tsx
Created August 17, 2023 18:59
Component button using React with typescript and ReactNode
import React, { ReactNode } from 'react'
type ButtonProps = {
lenghtButton?: string;
children: ReactNode;
onClick?: () => void
};
export const Button = (props: ButtonProps) => {
return (
<button onClick={props.onClick} style={{fontSize: props.lenghtButton}}>
@paulodutra
paulodutra / Button-PropsWithChildren.tsx
Last active August 17, 2023 19:02
Component button using React with typescript and PropsWithChildren
import React from 'react'
type ButtonProps = React.PropsWithChildren<{
lenghtButton?: string;
onClick?: () => void
}>
export const Button = ({children, lenghtButton, onClick}: ButtonProps) => {
return (
<button onClick={onClick} style={{fontSize: lenghtButton}}>
@paulodutra
paulodutra / Button-ComponentProps.tsx
Created August 17, 2023 19:03
Component button using React with typescript and ComponentProps
import React from 'react'
type ButtonProps = React.ComponentProps<"button"> & {
lenghtButton?: string
}
export const Button = ({children, lenghtButton, ...props}: ButtonProps) => {
return (
<button
style={{fontSize: lenghtButton}}
{...props}
@paulodutra
paulodutra / Checkbox-ChangeEventHandler.tsx
Created August 18, 2023 13:13
An example of checkbox component using the React.ChangeEventHandle to set value
import React from 'react'
export const Checkbox = ({ label} : {label: string}) => {
const [value, setValue] = React.useState(false);
const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {
setValue(event.currentTarget.checked)
}
return (
<label style={{
padding: "1rem",