Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: ctverce.py new file: prvocislo.py new file: soucty.py
- Loading branch information
1 parent
60b96e8
commit 2938e2b
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf8 -*- | ||
# Soubor: ctverce.py | ||
# Datum: 04.12.2013 08:37 | ||
# Autor: Marek Nožka, nozka <@t> spseol <d.t> cz | ||
# Licence: GNU/GPL | ||
# Popis: program generuje náhoná čísla | ||
# potom počítá součet jejich čtverců | ||
############################################################################ | ||
|
||
import random | ||
|
||
#print random.randint(-10,10) | ||
cisla=[] | ||
for i in range(4): | ||
cisla=cisla+[random.randint(0,5)] | ||
|
||
print cisla | ||
|
||
soucet=0 | ||
for x in cisla: | ||
mocnina = x*x | ||
soucet = soucet + mocnina | ||
|
||
print "sucet je ", soucet |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf8 -*- | ||
# Soubor: prvocislo.py | ||
# Datum: 04.12.2013 09:18 | ||
# Autor: Marek Nožka, nozka <@t> spseol <d.t> cz | ||
# Licence: GNU/GPL | ||
# Úloha: zjisti jestli je zadané číslo prvočíslo | ||
############################################################################ | ||
|
||
cislo = input('zadej cislo > ') | ||
|
||
for i in range(2,cislo): | ||
if cislo % i == 0 : # cislo je delitelne i | ||
print "NEEEEE" | ||
print "je delitelne", i | ||
exit() | ||
print "Ano ANO Hurá" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf8 -*- | ||
# Soubor: soucty.py | ||
# Datum: 04.12.2013 08:37 | ||
# Autor: Marek Nožka, nozka <@t> spseol <d.t> cz | ||
# Licence: GNU/GPL | ||
# Popis: program sečte zvláš všechna kladná čísla | ||
# a zvlášť všechna záporná čísla | ||
############################################################################ | ||
|
||
import random | ||
|
||
cisla=[] | ||
for i in range(6): | ||
cisla=cisla+[random.randint(-5,5)] | ||
|
||
print cisla | ||
|
||
kladna=0 | ||
zaporna=0 | ||
for x in cisla: | ||
if x<0 : | ||
zaporna += x # stejné jako zaporna = zaporna + x | ||
else: | ||
kladna = kladna + x | ||
|
||
print kladna, zaporna |