Poprawki AiSD

This commit is contained in:
2025-05-15 15:25:50 +02:00
parent 9fb3babfa0
commit 72826f26b6
8 changed files with 40 additions and 51 deletions
@@ -0,0 +1,20 @@
import math;
a = float(input("Podaj a: "))
b = float(input("Podaj b: "))
c = float(input("Podaj c: "))
if(a==0):
x=c/b
print("To jest rownanie liniowe\n", x)
else:
Delta=b*b-4*a*c
if (Delta < 0):
print("Brak rozwiazan")
elif (Delta > 0):
x1=(-b - math.sqrt(Delta))/(2*a)
x2=(-b + math.sqrt(Delta))/(2*a)
print('Dwa pierwiastki\n', x1,'\n', x2)
else:
x=b/(2*a)
print('Jeden pierwiastek\n',x);
@@ -0,0 +1,15 @@
def Czytaj_rok():
rok = int(input("Podaj rok: "))
return rok;
def Czy_przestepny(rok):
return ((rok%4==0) and not (rok%100==0)) or (rok % 400 == 0)
def Wypisz_czy_przestepny(rok,przestepny):
if(przestepny):
print("Rok", rok, "jest przestepny")
else:
print("Rok", rok, "nie jest przestepny")
def Glowna_procedura():
rok = Czytaj_rok()
Wypisz_czy_przestepny(rok,Czy_przestepny(rok))
Glowna_procedura()
@@ -0,0 +1,16 @@
from math import trunc
def Czytaj_liczbe():
return int(input("Podaj liczbe: "))
def Suma_cyfr(liczba):
suma=0
liczba=abs(liczba)
while(liczba>0):
suma=suma+(liczba%10)
liczba=int(trunc(liczba/10))
return suma
def Wypisz_wynik(liczba,suma):
print("Suma cyfr liczby",liczba,"to",suma)
def Glowna_procedura():
liczba=Czytaj_liczbe()
Wypisz_wynik(liczba,Suma_cyfr(liczba))
Glowna_procedura()