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
# Jedna od tehnika koje se koriste pri razbijanju neke jednostavnije forme enkripcije je utvrđivanje koja slova se u | |
# nekom tekstu najčešće pojavljuju. Zatim se ona mapiraju sa najučestalijim slovima iz datog jezika. Ne znam koja su | |
# najučestalija slova u srpskom, ali uz ovaj program možemo to utvrditi, ako uzmemo dovoljno velik uzorak. Ovaj program | |
# broji koliko se svako slovo teksta puta ponavlja i ispisuje # sortiranu tabelu u formatu po izboru: | |
# "slovo = broj ponavljanja" ili "broj ponavljanja = slovo=. Korisnik prilikom pokretanja programa navodi ime fajla | |
# za analizu. Program ga upozorava ako to nije učinio ili ako nije u stanju da otvori traženi fajl. | |
import sys | |
import re | |
import string |
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 program koji nalazi najdužu reč/reči u tekstu. Prvo uklanja | |
# svu interpunkciju, a na kraju ispisuje odgovarajuću poruku, | |
# koja uključuje broj slova najduže reči, zajedno sa svim rečima | |
# te dužine koje se nalaze u tekstu. | |
# | |
import re | |
import string | |
with open('novi.txt', 'r') as fajl: |
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 sys | |
# Provera da su dati svi argumenti. | |
if len(sys.argv) != 3: | |
print("Unesi ime 2 fajla u komandnoj liniji.") | |
quit() | |
try: | |
novi = open(sys.argv[2], "w") | |
with open(sys.argv[1], 'r') as f: |
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 sys | |
# provera da su uneta sva četiri argumenta; prvi je ime programa .py | |
if len(sys.argv) != 4: | |
print("Unesi ime sva 3 fajla u komandnu liniju") | |
quit() | |
data1 = data2 = '' | |
fajl1 = open(sys.argv[1], "r") |
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
# Prikaži poslednjih 10 linija učitanog tekstualnog fajla, pri čemu je ime fajla argument na comandnoj liniji, | |
# posle naziva programa. | |
# | |
import sys | |
BR_REDOVA = 10 | |
# Provera da je argument dat. | |
if len(sys.argv) != 2: | |
print("Unesi ime fajla u komandnoj liniji.") |
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
poruka = input('Unesi tekst. Program će prebrojati koliko \nu njemu ima unikatnih slova i znakova? ') | |
slova = '' | |
for i in poruka: | |
if i not in slova: | |
if i != ' ': | |
slova = slova + i | |
print() | |
print('Ima', len(slova), 'slova i znakova:') | |
print(slova) |
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
recnik = {1 : 'jedan', 2 : 'dva', 3 : 'tri', 4 : 'četiri', 5 : 'pet', 6 : 'šest', 7 : 'sedam', 8 : 'osam', | |
9 : 'devet', 10 : 'deset', 11 : 'jedanaest', 12 : 'dvanaest', 13 : 'trinaest', 14 : 'četrnaest', | |
15 : 'petnaest', 16 : 'šesnaest', 17 : 'sedamnaest', 18 : 'osamnaest', 19 : 'devetnaest', | |
20 : 'dvadeset', 30 : 'trideset', 40 : 'četrdeset', 50 : 'pedeset', 60 : 'šezdeset', 70 : 'sedamdeset', | |
80 : 'osamdeset', 90 : 'devedeset', 100 : 'sto', 200 : 'dvesta', 300 : 'trista', 400 : 'četristo', | |
500 : 'petsto', 600 : 'šesto', 700 : 'sedamsto', 800 : 'osamsto', 900 : 'devetsto', 1000 : 'hiljadu'} | |
broj = int(input('Unesi pozitivan broj od 1 do 1000: ')) | |
if 0 < broj < 20: |
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
morse = {'A': '.-', 'B': '-...', 'C': '-.-.', 'Č': '-..-', 'Ć': '--.-', 'D': '-..', 'DŽ': '-.--', 'Đ': '..-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'Š': '----', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', 'Ž': '.--', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.', '0': '-----', '.': '.-.-.-', ',': '--..--', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--', '-': '-....-', '/': '-..-.', '()': '..-.'} | |
poruka1 = [] | |
poruka2 = [] | |
biraj = input('Kako unosis poruku? (M za morzea, A za alfabet) ').upper() | |
if biraj == 'M': | |
por = input('Unesi poruku (ENTER to quit): ').upper() | |
poruka1 = por.split() |
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
# Od tri zadata broja pronađi koji je najveći neparni. | |
x, y, z = 63, 81, 27 | |
if x%2 != 0: | |
if y%2 != 0: | |
if z%2 != 0: | |
if x > y and x > z: | |
print('Najveći neparni broj je:', x) | |
elif y > z: |
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
Kako da sabiraš ili oduzimaš ovakve stringove? | |
'1plus2plus3plus4' | |
rezultat = 10 | |
ili: | |
'1plus2plus3minus4' | |
rezultat = 2 [/quote] | |
******************************* | |
def calculate(s): |