-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dce117b
commit e88ecdf
Showing
46 changed files
with
843 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
print('Hello World') | ||
|
||
#assigning values | ||
x = 8 #Integer value (int) | ||
y = 9 #Integer value (int) | ||
valor_float = 3.14159 #Float value (float) | ||
z = 'python e 10' #String value (str) | ||
|
||
#showing values(You can use "," or "+" or .format()) | ||
print(' x =', x) | ||
print(' y ='+ y) | ||
print(' z = {}'.format(z)) | ||
print(' float value =',valor_float) | ||
|
||
#one way to do a | ||
print('x < y = ', x < y) | ||
|
||
#operacoes | ||
|
||
soma = x + y | ||
sub = x - y | ||
divisao = x / y | ||
div_int = x // y #Divisao inteira | ||
div_rest = x % y #sobra da divisao | ||
pot = x ** 2 #Potencia | ||
poty = y ** 2 #Potencia | ||
|
||
#PRINT # A "," serve para concactenar | ||
|
||
print('x + y = ', soma) | ||
print('x - y = ', sub) | ||
print('x / y = ', divisao) | ||
print('x // y = ', div_int) | ||
print('x % y = ', div_rest) | ||
print('x ** 2 = ', pot) | ||
print('y ** 2 = ', poty) | ||
print('---- Mostrando todas variaveis ----') | ||
print(x, y, z) | ||
|
||
#tipos de variaveis | ||
|
||
print('tipo de x= ',type(x)) | ||
print('tipo de y= ',type(y)) | ||
print('tipo de z= ',type(z)) | ||
|
||
#converter variaveis | ||
valor_int = int(valor_float) | ||
print('valor float convertido para inteiro', valor_int) | ||
|
||
#Tamanho do texto | ||
|
||
print('tamanho de z =', len(z)) | ||
|
||
#nao consigo colocar len(valor_float) pois o len e utilizado somente para string entao converta para string | ||
valor_str = str(valor_float) | ||
print('tamanho do valor float =', len(valor_str)) | ||
|
||
|
||
n = 1j | ||
print('numero complexo', type(n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
segundo = input("Digite o valor em segundos: ") | ||
seg = int(segundo) | ||
|
||
hr = seg // 3600 | ||
dia = hr // 24 | ||
hr_final = hr % 24 | ||
seg_restante = seg % 3600 | ||
minuto = seg_restante // 60 | ||
seg_final = seg_restante % 60 | ||
|
||
print("Dia: {} Hora: {} Minuto: {} Segundo: {}".format(dia,hr_final,minuto, seg_final)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
temperaturafahrenheit = input('Digite uma temperatura em F:') | ||
|
||
temperatura_c = (float(temperaturafahrenheit) - 32)*5/9 | ||
|
||
print('A temperatura em Celsius é:', temperatura_c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#retorna true | ||
print('5 > 3 = ', 5 > 3 ) | ||
|
||
#retorna o tipo bool | ||
print(type(5 > 3)) | ||
|
||
#tipo ( falso ) | ||
#and, or e not not= true vai ser false e false vai ser true | ||
|
||
print('5 > 3 and 5 == 3', 5 > 3 and 5 == 3) | ||
print('5 > 3 or 5 == 3', 5 > 3 or 5 == 3) | ||
print('not 5 > 3 ', not 5 > 3) | ||
|
||
print('--------------------------------------------') | ||
print('|Nivel | Categoria | Operador |') | ||
print('|------------------------------------------|') | ||
print('|7(alto) | exponete | ** |') | ||
print('|6 | multiplicacao | *,/,//,% |') | ||
print('|5 | adicao | +,- |') | ||
print('|4 | relacional | ==,!=,<=,>=,>,< |') | ||
print('|3 | logico | not |') | ||
print('|2 | logico | and |') | ||
print('|1(baixo)| logico | or |') | ||
print('--------------------------------------------') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tmp = int(input('Escreva uma temperatura:')) | ||
if tmp > 40: | ||
print('ERRE JOTA 40 GRAUS') | ||
print('temperatura maior que 40 graus') | ||
else: | ||
print('Temperatura menor que 40 graus') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
x = int(input("Digite até onde você quer ver potencias de 2:")) | ||
i = 0 | ||
while i <= x: | ||
print('2 ^',i, '=',2 ** i) | ||
i = i + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
def soma (x, y): | ||
return x + y | ||
|
||
n1 = int(input('Digite um número ')) | ||
n2 = int(input('Digite outro numero ')) | ||
|
||
print('A soma dos números é: ', soma(n1,n2)) | ||
|
||
def nome_do_seu_time (): | ||
return 'Time' | ||
|
||
print(nome_do_seu_time) | ||
|
||
def nao_retorna (): | ||
x = 489 * 893 * 5 /9+78 | ||
print('Essa função calculou ', x ,' mas não retorna nada') | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#array / lista / vetores | ||
|
||
lista_de_palavras = ['laranja', 'maça', 'pera', 'uva'] | ||
lista_de_numeros = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] | ||
|
||
print(lista_de_palavras[0], lista_de_numeros[0], lista_de_numeros[9], lista_de_palavras[3] ) | ||
|
||
#numeros negativos pega do fim para o inicio | ||
print(lista_de_numeros[-1]) | ||
|
||
def primo(x): | ||
fator = 2 | ||
if(x == 2): | ||
return(True) | ||
while(x % fator != 0 and fator <= x/2): | ||
fator += 1 | ||
if(x % fator == 0): | ||
return False | ||
else: | ||
return True | ||
|
||
limite = int(input('Limite maximo:')) | ||
n = 2 | ||
p = [] | ||
while n < limite: | ||
if primo(n): | ||
p.append(n) | ||
print(n, end=', ') | ||
n += 1 | ||
|
||
print('Quantidade de números primos: ', len(p)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fruta = ['laranja', 'maça', 'pera', 'uva'] | ||
for i in fruta: | ||
print('Eu não gosto de', i) | ||
|
||
#for i in rage(fim): <--- (0, fim) | ||
# comando | ||
#for i in rage(ini, fim) | ||
# comando | ||
#for i in rage(ini, fim, passo) <---- de tanto a tanto com certo intervalo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def cria_matriz(x, y): | ||
'''X para o valor das colunas, Y para o valor das linhas ''' | ||
matriz = [] | ||
for i in range(y): | ||
linha = [] | ||
for j in range(x): | ||
linha.append(int(input('Digite um valor('+ str(i) +')(' + str(j)+ ')'))) | ||
matriz.append(linha) | ||
return imprime(matriz, y) | ||
|
||
def imprime(m, y): | ||
i = 0 | ||
while i < y: | ||
print(m[i]) | ||
i += 1 | ||
|
||
def main(): | ||
lin = int(input('Digite o número de linhas da matriz: ')) | ||
col = int(input('Digite o número de colunas da matriz: ')) | ||
|
||
cria_matriz(lin, col) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import math | ||
a = int(input('a:')) | ||
b = int(input('b:')) | ||
c = int(input('c:')) | ||
|
||
def bhaskara (a, b, c): | ||
return (-b+math.sqrt(delta(a,b,c)))/2*a | ||
|
||
def delta (a, b, c): | ||
return (b**2)-4*a*c | ||
|
||
if delta(a,b,c) > 0: | ||
print('as raízes da equação são', bhaskara(a, b, c), ' e ', bhaskara(a, b, c)) | ||
elif delta(a,b,c) == 0: | ||
print('a raiz desta equação é', bhaskara(a, b, c)) | ||
elif delta(a,b,c) < 0: | ||
print('esta equação não possui raízes reais') | ||
else: | ||
print('Digite números válidos') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import math | ||
a = int(input('a:')) | ||
b = int(input('b:')) | ||
c = int(input('c:')) | ||
|
||
delta = (b**2)-4*a*c | ||
if delta > 0: | ||
print('as raízes da equação são', (-b+math.sqrt(delta))/2*a, ' e ', (-b-math.sqrt(delta))/2*a) | ||
elif delta == 0: | ||
print('a raiz desta equação é', (-b+math.sqrt(delta))/2*a) | ||
elif delta < 0: | ||
print('esta equação não possui raízes reais') | ||
else: | ||
print('Digite números válidos') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
n = int(input()) | ||
if n % 5 == 0: | ||
print('Buzz') | ||
else: | ||
print(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def fatorial (n) | ||
fat = 1 | ||
while (n > 1): | ||
fat = fat * n | ||
n = n - 1 | ||
return fat | ||
|
||
def coeficiente_binominal (n, k): | ||
return fatorial(n) / (fatorial(k) * fatorial(n-k)) | ||
|
||
n = int(input('Digite o valor de n: ')) | ||
k = int(input('Digite o valor de k: ')) | ||
print(coeficiente_binominal(n, k)) |
Oops, something went wrong.