test 2 python Flashcards

1
Q

napiši funkcijo, ki iz podanega niza znakov odstrani vse samoglasnike. funkcija naj vrne niz brez samoglasnikov. npr brez (-informatika-) vrne infrmtk

A

def brez(beseda):
samoglasniki = “aeiou”
novabeseda = “”
for x in beseda :
if x not in samoglasniki:
novabeseda += n
return(novabeseda)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

napiši funkcijo ki kot parameter sprejme naravno število in vrne seznam vseh deliteljev tega števila. nor delitelji (6) vrne (1,2,3,6)

A

def delitelji (x):
seznam = ()
for n in range (1, x):
if x % seznam == 0:
seznam. append(n)
return seznam

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

napiši fukncijo ki kot parametre sprejme 3 števila in ugotovi če sp števila različna. če so različna naj vrne True sicer False.

A

def razlicna (a,b,c)
if a == b and b ==c
x = false
else :
x = true
return x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

napisi fukncijo ki kot parameter prejme niz in vrne število samoglasnikov v tem nizu. npr samoglasniki (informatika) vrne 5

A

def samoglasniki (beseda)
stevilo = 0
samoglasniki = “aeiou”
for n in beseda:
if n in samoglasniki:
stevilo += 1
return(stevilo)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

napisi fukncijo ki kot parameter prejme števila a, q in n in nato vrne seznam z n členi geometrijskega zaporedja a: aq, aq…,

A

def geometrijsko (a, q, n)
seznam = ()
for i in range (n)
seznam.append (a*q**i)
return seznam

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

napisi funkcijo ki kot parameter sprejme seznam števil in vrne aritmeticno sredino teh stevil. (vsota deljeno n ) npr. aritmeticna (1,3,8) vrne 4

A

def aritmeticna (seznam):
return sum(seznam) / len (seznam)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

napiši fukncijo ki kot parameter prejme seznam števil in vrne seznam v katerem so le soda števila podanega seznama.

A

def soda(seznam)
sodast = ()
for n in seznam:
if n % 2 == 0
sodast.apprend(n)
return sodast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

napiši fukncijo ki kot parameter orejme števia a, d , in natoe izpiše (print) n členov aritmetičnega zaporedja : a, a+d, a+2d..

A

def aritmetično(a,d,n)
st = ()
for i in range(0,n)
st.apprend(a+d*i)
return pritn(st)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

zapiši fukncijo ki kot parametre prejme 3 števila in pove če so to lahko stranice triktonika

A

def trikotnik (a,b,c)
if a +b<= c or if a+c <=b or if b +c <=a :
x = false
else :
x = true
return x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly