Last active
December 4, 2017 19:19
-
-
Save haam3r/1f2ca4801b4a8f037bd8eec7cca813bf to your computer and use it in GitHub Desktop.
Vaiba pikkuste arvutamine
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
def lõimede_pikkus(vaiba_lõpp_pikkus, lõimede_arv): | |
return (round(lõimede_arv * (vaiba_lõpp_pikkus * 1.2 + 0.5), 2)) | |
failinimi = input("Sisestage failinimi: ") | |
lõimede_arv1 = int(input("Sisestage 5-meetriste ja pikemate vaipade lõimede arv: ")) | |
lõimede_arv2 = int(input("Sisestage lühemate vaipade lõimede arv: ")) | |
vaiba_lõpp_pikkus = [] | |
fail = open(failinimi, encoding="UTF-8") | |
for rida in fail: | |
vaiba_lõpp_pikkus += [float(rida)] | |
lõimede_kogupikkused = [] | |
for pikkus in vaiba_lõpp_pikkus: | |
if pikkus >= 5: | |
tegelik_pikkus = lõimede_pikkus(pikkus, lõimede_arv1) | |
else: | |
tegelik_pikkus = lõimede_pikkus(pikkus, lõimede_arv2) | |
print(tegelik_pikkus) | |
lõimede_kogupikkused += [tegelik_pikkus] | |
kokku = 0 | |
for tegelik_pikkus in lõimede_kogupikkused: | |
kokku += tegelik_pikkus | |
print("Kõigi vaipade peale läheb vaja " + str(kokku) + " meetrit lõimeniiti.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment