Hack Bulgaria
github.com/HackBulgaria
>>> 5
5
>>> 5 + 5
10
>>> "Hack" + "Bulgaria"
"HackBulgaria
>>> 1 + (randint(1, 6) + total_sum) * times
sum = 0
repeat = 5
while repeat > 0:
sum = sum + repeat
repeat = repeat - 1
age = input("Enter age?")
age = int(age)
if age < 18:
print("You are not allowed here")
if age < 18:
print("You are not allowed here")
else:
print("Hello there!")
if age < 18:
print("You are not allowed here")
elif age == 18:
print("You barely made it here!")
elif age == 33:
print("Anything special about that age?")
if age < 18:
print("You are not allowed here")
elif age == 18:
print("You barely made it here!")
elif age == 33:
print("Anything special about that age?")
else:
print("You are > 18 but not 18 and 33")
# Variable assingment is a statement
a = 5
contents = open("alumni.txt").read().split("\n")
csv = []
for person in contents:
person = person.replace(" - ", ",")
csv.append(person)
csv_content = "\n".join(csv)
file = open("alumni.csv", "w")
file.write(csv_content)
if age > 18 and money >= 50:
print("You can enter the club")
if talking_on_the_phone or without_seatbelt:
print("Приятно ми е, полицай Георгиев!")
money = money - 20
if not sleeping:
print("You are awake!")
if "Rado" in "RadoRado":
print("I found the Rado")
name = input("What is your name?")
search = "Yordanov Georgiev"
if search not in name:
print("All is fine. You can continue")
else:
print("Please step outside the car!")
from random import randint
sides = input("Enter dice sides: ")
sides = int(sides)
player1_name = input("Enter player1 name: ")
player2_name = input("Enter player2 name: ")
player1_dice_roll = randint(1, sides)
player2_dice_roll = randint(1, sides)
print(player1_name + " rolled: " + str(player1_dice_roll))
print(player2_name + " rolled: " + str(player2_dice_roll))
if player1_dice_roll == player2_dice_roll:
print("Tie!")
elif player1_dice_roll > player2_dice_roll:
print("The winner is: " + player1_name)
else:
print("The winner is: " + player2_name)
# while.py
counter = 0
while counter <= 5:
print(counter)
counter = counter + 1
while bool_expr:
print("Runs while bool_expr is True")
print("The first False breaks the cycle")
while False:
print("No one reaches me ;(")
while True:
print("You are forever under my control!")
counter = 0
while True:
counter = counter + 1
if counter == 10:
break
print(counter)
By Hack Bulgaria