Skip to content

Commit

Permalink
St 04.12.2013 09:44
Browse files Browse the repository at this point in the history
new file:   ctverce.py
new file:   prvocislo.py
new file:   soucty.py
  • Loading branch information
MarrekNozka committed Dec 4, 2013
1 parent 60b96e8 commit 2938e2b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ctverce.py
@@ -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
17 changes: 17 additions & 0 deletions prvocislo.py
@@ -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á"
27 changes: 27 additions & 0 deletions soucty.py
@@ -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

0 comments on commit 2938e2b

Please sign in to comment.