-
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
b03f262
commit f89a226
Showing
34 changed files
with
591 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,21 @@ | ||
val = [] | ||
c = 0 | ||
while True: | ||
n = int(input('Add an integer number ')) | ||
if n not in val: | ||
if c == 0 or n > val[-1]: | ||
val.append(n) | ||
c += 1 | ||
else: | ||
p = 0 | ||
while p < len(val): | ||
if n <= val[p]: | ||
val.insert(p, n) | ||
break | ||
p += 1 | ||
else: | ||
print('A number cannot be added twice') | ||
b = input('Wanna continue? (Enter/n) ') | ||
if b == 'n': | ||
break | ||
print(f'The final list is {val}') |
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 @@ | ||
# Approved or Reproved | ||
dic = dict() | ||
dic['name'] = str(input('Name: ')) | ||
dic['grade'] = float(input('Grade: ')) | ||
if dic['grade'] >= 7: | ||
dic['sit'] = 'AP' | ||
for k, v in dic.items(): | ||
print(f'{k} = {v}') | ||
print(f"Congrats, {dic['name']}!") | ||
else: | ||
dic['sit'] = 'RP' | ||
for k, v in dic.items(): | ||
print(f'{k} = {v}') | ||
print(f"You must study more, {dic['name']}") |
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,22 @@ | ||
import time | ||
term = int(input('Tell the first term: ')) | ||
reason = int(input('Tell the reason: ')) | ||
counter = 0 | ||
while counter != 10: | ||
term += reason | ||
counter += 1 | ||
time.sleep(1) | ||
print(term) | ||
repeater = float | ||
while repeater != 'n': | ||
repeater = input('Wanna print more terms? ') | ||
counter2 = 0 | ||
if repeater == 'y': | ||
cont = int(input('How many do you want? ')) | ||
while counter2 != cont: | ||
term += reason | ||
counter2 += 1 | ||
time.sleep(1) | ||
print(term) | ||
else: | ||
print('\n\nThe code ended') |
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 @@ | ||
# Four players and a dice | ||
from random import randint | ||
from time import sleep | ||
from operator import itemgetter | ||
game = dict() | ||
for c in range(1, 5): | ||
game[f'Player{c}'] = randint(1, 20) | ||
print(f"Player {c} got {game[f'Player{c}']}") | ||
sleep(1) | ||
rank = sorted(game.items(), key=itemgetter(1), reverse=True) | ||
for rn, rv in enumerate(rank): | ||
print(f"{rn+1}° place: {rv[0]} --- {rv[1]}") | ||
sleep(0.5) |
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,15 @@ | ||
def factorial(num): | ||
from time import sleep | ||
c = 1 | ||
for n in range(num, 0, -1): | ||
if n > 1: | ||
print(n, 'x ', end='') | ||
sleep(0.8) | ||
else: | ||
sleep(0.8) | ||
print(n, '= ', end='') | ||
c *= n | ||
return c | ||
|
||
|
||
print(factorial(int(input('Integer number to do factorial: ')))) |
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,10 @@ | ||
from time import sleep | ||
num1 = int(input('Type the initial number for an Fibonacci sequence: ')) | ||
num2 = int(input('Type the second number of this sequence: ')) | ||
ran = int(input('How many times you want to rerun the sum? ')) | ||
for c in range(0, ran): | ||
num3 = num1 + num2 | ||
num1 = num2 | ||
num2 = num3 | ||
sleep(1) | ||
print(num3) |
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,12 @@ | ||
# Aritmetical operations | ||
n1 = int(input('Number 1:')) | ||
n2 = int(input('Number 2:')) | ||
s = n1 + n2 | ||
sub = n1 - n2 | ||
d = n1 / n2 | ||
p = n1 ** n2 | ||
m = n1 * n2 | ||
di = n1 // n2 | ||
redi = n1 % n2 | ||
print('Sum:{}\nSubtraction:{}\nDivision:{:.2f}\nMultiplication:{}'.format(s, sub, d, m)) | ||
print('Power:{}\nInteger division:{}\nRest of division:{}'.format(p, di, redi)) |
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,50 @@ | ||
from time import sleep | ||
|
||
|
||
def line(): | ||
print('~' * 30) | ||
|
||
|
||
players = dict() | ||
team = list() | ||
matches = list() | ||
while True: | ||
players.clear() | ||
players['name'] = input("Player's name: ") | ||
matchesp = int(input(f"How many matches did {players['name']} played? ")) | ||
for c in range(0, matchesp): | ||
matches.append(int(input(f"How many goals at the match number {c+1}? "))) | ||
players['goals'] = matches[:] | ||
players['mplayed'] = matchesp | ||
players['tgoals'] = sum(players['goals']) | ||
team.append(players.copy()) | ||
matches.clear() | ||
breaker = str(input('Any more players? [space(y)/(n)]')) | ||
if breaker == 'n': | ||
break | ||
line() | ||
print(f"{'Table of results':.^28}") | ||
line() | ||
print('Code', end='') | ||
for i in players.keys(): | ||
print(f'{i:<15}', end='') | ||
print() | ||
for k, v in enumerate(team): | ||
print(f"\n{k:>3}", end='') | ||
for i in v.values(): | ||
print(f"{str(i):<15}", end='') | ||
print() | ||
while True: | ||
line() | ||
search = int(input("Search for a player if you want('999' to end): ")) | ||
if search == 999: | ||
print('<End of the code>') | ||
break | ||
elif search > len(team): | ||
print('There is no player with this number') | ||
else: | ||
print(f"Player n°{search}, {team[search]['name']}") | ||
for k, v in enumerate(team[search]['goals']): | ||
print(f'At the match {k}, made {v} goal(s)') | ||
sleep(0.5) | ||
# Not self-made :( |
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 @@ | ||
# Ink efficiency | ||
|
||
ww = float(input('Type the width of the object:')) | ||
wh = float(input('Type the height of the object:')) | ||
a = ww * wh | ||
iq1 = (a / 5) | ||
iq2 = (a / 10) | ||
iq3 = (a / 20) | ||
iq4 = (a / 40) | ||
if a < 5: | ||
print('Area of the object:{:.1f}\nQuantity of gallons of 1L:{:.1f}'.format(a, iq1)) | ||
if 10 > a >= 5: | ||
print('Area of the object:{:.1f}\nQuantity of gallons of 5L:{:.1f}'.format(a, iq2)) | ||
if 20 > a >= 10: | ||
print('Area of the object:{:.1f}\nQuantity of gallons of 10L:{:.1f}'.format(a, iq3)) | ||
if 40 > a >= 20: | ||
print('Area of the object:{:.1f}\nQuantity of gallons of 20L:{:.1f}'.format(a, iq4)) | ||
if a > 40: | ||
print('Area of the object:{:.1f}\nQuantity of gallons of 20L:{:.1f}'.format(a, iq4)) |
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,12 @@ | ||
gender = str | ||
while gender != 'm' or gender != 'f': | ||
gender = str(input('Tell your gender: ')) | ||
if gender == 'm': | ||
print('You are a man') | ||
break | ||
if gender == 'f': | ||
print('You are a woman') | ||
break | ||
if gender != 'm' or 'f': | ||
print('You are not a/an {}'.format(gender)) | ||
print('This code only accept the original genders') |
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,12 @@ | ||
ores = ('iron', 'bronze', 'silver', 'gold', 'diamond', 'ruby', 'emerald', 'lapis lazuli', 'aluminium', | ||
'barium', 'strontium', 'magnesium', 'copper', 'opal', 'aquamarine', 'moonstone', | ||
'bloodstone', 'topaz', 'garnet', 'agate', 'citrine', 'zircon', 'amethyst') | ||
print(f"{'|Mineral and Gems|':<25}{'Letters A':>}{'Letters E':>10}" | ||
f"{'Letters I':>10}{'Letters O':>10}{'Letters U':>10}") | ||
for ore in range(0, len(ores)): | ||
print(f'{ores[ore]:<25}', end='') | ||
print(f'{ores[ore].count("a"):>5}', end='') | ||
print(f'{ores[ore].count("e"):>10}', end='') | ||
print(f'{ores[ore].count("i"):>10}', end='') | ||
print(f'{ores[ore].count("o"):>10}', end='') | ||
print(f'{ores[ore].count("u"):>10}') |
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,20 @@ | ||
import time | ||
import random | ||
games = [] | ||
bets = [] | ||
print(f"{'Lottery':~^30}") | ||
quant = int(input('How many games do you need? ')) | ||
c = 0 | ||
while c < quant: | ||
n = 0 | ||
while n < 6: | ||
num = random.randint(1, 60) | ||
if n == 0 or num not in bets: | ||
bets.append(num) | ||
n += 1 | ||
games.append(bets[:]) | ||
print(f'Game {c+1}: {games[c]}') | ||
bets.clear() | ||
c += 1 | ||
time.sleep(1.2) | ||
print(f"{'Bets ready, good luck!':~^30}") |
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 @@ | ||
exp = input('Type an mathematical expression below which use parenthesis\n ') | ||
exp_run = exp | ||
if not exp_run: | ||
print('This expression is incorrect') | ||
else: | ||
print(f'The expression {exp} is correct') |
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 @@ | ||
import random | ||
numbers = (random.randint(0, 10), random.randint(0, 10), random.randint(0, 10), | ||
random.randint(0, 10), random.randint(0, 10)) | ||
print(f'Aleatory numbers: {numbers}') | ||
print(f'Highest: {max(numbers)}') | ||
print(f'Lowest: {min(numbers)}') |
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,8 @@ | ||
numbers = [] | ||
while True: | ||
numbers.append(int(input('Type any integer number: '))) | ||
stop = input('Wanna continue? ') | ||
if stop == 'n': | ||
break | ||
print(f'The minimum value is {min(numbers)} at the position {numbers.index(min(numbers))}') | ||
print(f'The maximum value is {max(numbers)} at the position {numbers.index(max(numbers))}') |
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,16 @@ | ||
values = [] | ||
numbers = [] | ||
b = str | ||
while b != 'n': | ||
numbers.append(int(input('Type any number: '))) | ||
values.append(numbers[:]) | ||
numbers.clear() | ||
b = input('Wanna continue? ') | ||
print('The even numbers are: ') | ||
for even in range(len(values)): | ||
if even % 2 == 0: | ||
print(f'{even}') | ||
print('The odd numbers are: ') | ||
for odd in range(len(values)): | ||
if odd % 2 != 0: | ||
print(f'{odd}') |
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 @@ | ||
people = [] | ||
data = [] | ||
heavy = light = 0 | ||
b = str | ||
while b != 'n': | ||
data.append(str(input('Name: '))) | ||
data.append(int(input('Weight: '))) | ||
if len(people) == 0: | ||
heavy = light = data[1] | ||
else: | ||
if data[1] > heavy: | ||
heavy = data[1] | ||
if data[1] < light: | ||
light = data[1] | ||
people.append(data[:]) | ||
data.clear() | ||
b = input('Wanna continue? ') | ||
print(f'The quantity of persons signed is {len(people)}') | ||
for p in people: | ||
if p[1] == heavy: | ||
print(f'Heaviest person: {p[0]}. {heavy} is its weight') | ||
for p in people: | ||
if p[1] == light: | ||
print(f'Lightest person: {p[0]}. {light} is its weight') |
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,33 @@ | ||
people = dict() | ||
persons = list() | ||
summ = average = 0 | ||
while True: | ||
people.clear() | ||
people['name'] = str(input('Name: ')) | ||
while True: | ||
people['gender'] = str(input('Gender(m/f): ').upper()[0]) | ||
if people['gender'] not in 'FfMm': | ||
print('Only true genders are accepted') | ||
else: | ||
break | ||
people['age'] = int(input('Age: ')) | ||
persons.append(people.copy()) | ||
summ += people['age'] | ||
breaker = input('Continue?(enter/n) ') | ||
if breaker == 'n': | ||
break | ||
average = summ / len(persons) | ||
for c in range(0, len(persons)): | ||
print(f"{persons[c]}") | ||
print(f"{len(persons)} people were registered") | ||
print(f"The average age is {average:5.2f}") | ||
print('Women: ', end='') | ||
for p in persons: | ||
if p['gender'] in 'Ff': | ||
print(f"{p['name']}", end='| ') | ||
print() | ||
print(f"Persons above average age: ", end=' ') | ||
for p in persons: | ||
if p['age'] > average: | ||
print(f"{p['name']} |-", end='') | ||
print('\nEnd of the code') |
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 @@ | ||
def file(n='No player', g=0): | ||
print(f'Player: {n}\nGoals:{g}') | ||
|
||
|
||
name = str(input('Player name: ')) | ||
goals = input('Goals: ') | ||
if goals.isnumeric(): | ||
goals = int(goals) | ||
else: | ||
goals = 0 | ||
if name.strip() == '': | ||
file(g=goals) | ||
else: | ||
file(name, goals) |
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,10 @@ | ||
enh = ('Fighter', 10000, 'Wizard', 10000, 'Lucky', 10000, | ||
'Healer', 10000, 'Hybrid', 10000, 'Thief', 10000, | ||
'Spellbreaker', 10000) | ||
print(f'{"Enchancements":=^35}') | ||
for position in range(0, len(enh)): | ||
if position % 2 == 0: | ||
print(f'{enh[position]:.<25}', end='') | ||
else: | ||
print(f'${enh[position]:>5.2f}') | ||
print(f'{"Not self-made":=^35}') |
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,12 @@ | ||
# Colocações | ||
classification = ('Milwaukee Bucks', 'Boston Celtics', 'Philadelphia 76ers', 'Cleveland Cavaliers', | ||
'New York Knicks', 'Brooklyn Nets', 'Atlanta Hawks', 'Miami Heat', 'Chicago Bulls', 'Toronto Raptors') | ||
print(f'The teams at the podium are: {classification[0:3]}\n' | ||
f'The last 4: {classification[-4:]}\n' | ||
f'Sorted by name: {sorted(classification)}' | ||
) | ||
while True: | ||
search = input("Looking for an specific team? ('n' to finish)\n") | ||
if search == 'n': | ||
break | ||
print(f'{search} is actually at the {classification.index(search)}th position') |
Oops, something went wrong.