Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
1.3 kB
14
Indexable
Never
import random

friends = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]

for i in friends:
    print(i)

print("#############")
# until 5
for i in range(5):
    print(friends[i])

print("#############")
# from 5 until 10
for i in range(4, 10, 2):
    print(friends[i])

print("#############")
for i in range(3):
    print("I am Learning Python")

print("#############")


for i in range(1, 11, 1):
    print(5 * i)

print("#############")
print(5 > 2)
print(5 < 2)
print(10 == 10)
print(3 != 3)

print("#############")
print(5 == 3 or 5 == 5)

print("#############")
marvel = 7
kallen = 4
erwin = 6
if marvel < kallen:
    print("marvel lose, kallen win")
elif marvel < erwin:
    print("marvel lose, erwin win")
else:
    print("marvel win")

print("#############")

# while True:
#     answer = input("Do You Wan to Stop ?")
#     if answer.lower() == "yes":
#         print("good bye")
#         break
#     else:
#         print("Lets do it again")

# one liner code/ short code
[print(i) for i in range(10)]

print("asd") if 5 >= 5 else print("dsa")


students = [100, 90, 80, 30, 40]

results = ["A" if i >= 90 else "B" if i >= 70 else "Failed" for i in students]

print(students)
print(results)


[print("im learning python") for i in range(3)]

# randomize char
p = "kallen"
rnd = random.sample(p, len(p))

print("".join(rnd))