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
# Ovo je igra pogađanja brojeva. | |
import random | |
tajniBroj = random.randint(1, 20) | |
print('Zamislio sam jedan broj između 1 i 20.') | |
print('Šta misliš koji je?') | |
print() | |
# Suparnik ima na raspolaganju 6 pokušaja. | |
for brojPokushaja in range(1, 7): |
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
# Zadatak broj 2: Collatzov niz | |
nekiBroj = int(input('Unesi neki broj: ')) | |
def collatz(nekiBroj): | |
if nekiBroj % 2 == 0: | |
print(nekiBroj // 2) | |
return nekiBroj // 2 | |
else: |
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
lista = [] | |
print('Unesi četiri artikla') | |
prvi = input('prvi: ') | |
drugi = input('drugi: ') | |
treci = input('treći: ') | |
cetvrti = input('cetvrti: ') | |
lista = [prvi, drugi, treci, cetvrti] | |
def zarez(artikal): |
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
a = int(input('Unesi prvi broj: ')) | |
b = int(input('Unesi drugi broj: ')) | |
c = int(input('Unesi treći broj: ')) | |
mn = min(a, b, c) | |
mx = max(a, b, c) | |
sr = a + b + c - mn - mx | |
print() | |
print('Sortirani brojevi su:') |
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
import random | |
print('Koliko puta da bacim novčić?') | |
while True: | |
odgovor = input() | |
if odgovor.isdecimal(): | |
brojBacanja = int(odgovor) | |
break | |
with open('pismo_glava.txt', 'a+') as file: |
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
# Cezarova šifra | |
poruka = input('Unesi poruku: ') | |
pomeranje = int(input('Za koliko mesta pomeriti slova? ')) | |
abc = 'abcčćdđefghijklmnoprsštuvzž' | |
n=len(abc) | |
for i in poruka: | |
if i in abc: | |
print(abc[(abc.index(i)+pomeranje) % n], end='') |
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
x = int(input('Širina: ')) | |
y = int(input('Visina: ')) | |
if x < 2 or y < 2: | |
print('Suviše mali broj.') | |
else: | |
print('*' * x) | |
for i in range (y-2): | |
print('*' + ' ' * (x - 2) + '*') | |
print('*' * x) |
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
import random | |
boja = ['p', 'h', 'k', 't'] | |
vrednost = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] | |
def napraviShpil(): | |
karte = [] | |
for i in boja: | |
for j in vrednost: | |
karte.append(j + i) |
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
def provera(): | |
if all(lista[i] <= lista[i+1] for i in range(len(lista)-1)): | |
return True | |
elif all(lista[i] >= lista[i+1] for i in range(len(lista)-1)): | |
return True | |
else: | |
return False | |
print(provera()) |
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
limit = int(input("Izlistaj proste brojeve do broja? ")) | |
brojevi = [] | |
for i in range(0, limit + 1): | |
brojevi.append(i) | |
brojevi[1] = 0 | |
p = 2 | |
while p < limit: | |
for i in range(p*2, limit + 1, p): | |
brojevi[i] = 0 | |
p = p + 1 |
OlderNewer