Created
February 27, 2016 13:13
-
-
Save kissgyorgy/72338288574c77ecd11f to your computer and use it in GitHub Desktop.
Python: pizza calculator calculates which is bigger
This file contains hidden or 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
| #!/usr/bin/env python2 | |
| # -*- coding: utf-8 -*- | |
| import math | |
| first_size = float(raw_input('Első pizza mérete (cm): ')) | |
| first_pieces = int(raw_input('Első pizza darabszáma: ')) | |
| second_size = float(raw_input('Második pizza mérete (cm): ')) | |
| second_pieces = int(raw_input('Második pizza darabszáma: ')) | |
| first_area = ((first_size / 2.0)**2 * math.pi * first_pieces) | |
| first_area = round(first_area, 2) | |
| second_area = (second_size / 2.0)**2 * math.pi * second_pieces | |
| second_area = round(second_area, 2) | |
| print "Első pizza területe: %s cm2" % first_area | |
| print "Második pizza területe: %s cm2" % second_area | |
| if first_area == second_area: | |
| print "A két pizza pontosan EGYENLŐ. Elképesztő, mi? :D" | |
| elif first_area > second_area: | |
| print "Az ELSŐ ({} cm-es) pizzából {} db a nagyobb.".format(first_size, first_pieces) | |
| else: | |
| print "A MÁSODIK ({} cm-es) pizzából {} db a nagyobb.".format(second_size, second_pieces) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment