The Brain Booster
Intermediate Python sololearn Course
INTERMEDIATE PYTHON PROGRAM CODE FILES
The Brain Booster
Letter Counter
text = input()
dict = {}
for t in text:
dict[t] = text.count(t)
print(dict)
Spelling Backwards
def spell(txt):
x = len(txt)
for a in range(0,x):
print(txt[x-1])
x-=1
txt = input()
spell(txt)
Shooting Game
class Enemy:
name = ""
lives = 0
def __init__(self, name, lives):
self.name = name
self.lives = lives
def hit(self):
self.lives -= 1
if self.lives <= 0:
print(self.name + ' killed')
else:
print(self.name + ' has '+ str(self.lives) + ' lives')
class Monster(Enemy):
def __init__(self):
super().__init__('Monster', 3)
class Alien(Enemy):
def __init__(self):
super().__init__('Alien', 5)
m = Monster()
a = Alien()
while True:
x = input()
if x == 'exit':
break
elif x == 'laser':
a.hit()
elif x == 'gun':
m.hit()
Registration System
try:
name = input()
#your code goes here
if len(name)<4:
raise NameError
except:
print("Invalid Name")
else:
print("Account Created")
Title Encoder
file = open("/usercode/files/books.txt", "r")
cont = file.readlines()
for line in cont:
words = line.split()
for word in words:
print(word[0],end="")
print()
file.close()
0 Comments