dodao cas3, cas4, napravio dir strukturu
This commit is contained in:
22
Cas3/kvadrat.py
Executable file
22
Cas3/kvadrat.py
Executable file
@@ -0,0 +1,22 @@
|
||||
# Kvadrat od crunch-eva/hash-eva
|
||||
|
||||
# while petlja
|
||||
|
||||
strana_kvadrata = int(input("Unesite duzinu strane kvadrata: "))
|
||||
|
||||
brojac = 0
|
||||
|
||||
while brojac < strana_kvadrata:
|
||||
print("#" * strana_kvadrata)
|
||||
brojac += 1
|
||||
|
||||
input()
|
||||
|
||||
# for petlja
|
||||
|
||||
strana = int(input("Unesite drugu duzinu strane kvadrata: "))
|
||||
|
||||
for brojac in range(strana):
|
||||
print("#" * strana)
|
||||
|
||||
input()
|
23
Cas3/nagadjanje_broja.py
Executable file
23
Cas3/nagadjanje_broja.py
Executable file
@@ -0,0 +1,23 @@
|
||||
# Pogadjanje nasumicnog broja
|
||||
|
||||
from random import randint
|
||||
|
||||
broj = randint(0, 100)
|
||||
|
||||
while True:
|
||||
print("Unesite 'p' ako zelite da pogadjate, 'q' ako zelite da izadjete.")
|
||||
izbor = input("Opcija: ")
|
||||
if (izbor == "p"):
|
||||
guess = int(input("Unesite broj koji mislite da je nasumicno generisan: "))
|
||||
if (guess == broj):
|
||||
print("Bravo, pogodili ste broj!")
|
||||
break
|
||||
else:
|
||||
print("Niste pogodili broj.")
|
||||
elif (izbor == "q"):
|
||||
print("Odustali ste od nagadjanja. Broj je bio " + str(broj))
|
||||
break
|
||||
else:
|
||||
print("Niste odabrali postojecu opciju.")
|
||||
|
||||
input()
|
16
Cas3/od_0_do_100.py
Executable file
16
Cas3/od_0_do_100.py
Executable file
@@ -0,0 +1,16 @@
|
||||
# Sa while petljom
|
||||
|
||||
broj = 0
|
||||
|
||||
while (broj <= 100):
|
||||
print(broj)
|
||||
broj += 1
|
||||
|
||||
input()
|
||||
|
||||
# Sa for petljom
|
||||
|
||||
for broj in range(101):
|
||||
print(broj)
|
||||
|
||||
input()
|
20
Cas3/od_100_do_0_sa_7.py
Executable file
20
Cas3/od_100_do_0_sa_7.py
Executable file
@@ -0,0 +1,20 @@
|
||||
# Svi brojevi od 100 do 0 ako su deljivi sa 7
|
||||
|
||||
# while petlja
|
||||
|
||||
broj = 100
|
||||
|
||||
while broj > 0:
|
||||
if (broj % 7 == 0):
|
||||
print(broj)
|
||||
broj -= 1
|
||||
|
||||
input()
|
||||
|
||||
# for petlja
|
||||
|
||||
for broj in range(100, 0, -1):
|
||||
if (broj % 7 == 0):
|
||||
print(broj)
|
||||
|
||||
input()
|
23
Cas3/pravougaoni_trougao.py
Executable file
23
Cas3/pravougaoni_trougao.py
Executable file
@@ -0,0 +1,23 @@
|
||||
# pravougaoni trougao
|
||||
|
||||
# while petlja
|
||||
|
||||
duzina_katete = int(input("Unesite duzinu kateta pravougaonog trougla: "))
|
||||
|
||||
brojac = 1
|
||||
|
||||
while brojac <= duzina_katete:
|
||||
print("A" * (brojac))
|
||||
brojac += 1
|
||||
|
||||
input()
|
||||
|
||||
# for petlja
|
||||
|
||||
kateta = int(input("Unesite duzinu katete drugog pravougaonog trougla: "))
|
||||
|
||||
for i in range(kateta):
|
||||
print("#" * (i + 1))
|
||||
|
||||
input()
|
||||
|
Reference in New Issue
Block a user