Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Created February 27, 2016 13:13
Show Gist options
  • Select an option

  • Save kissgyorgy/72338288574c77ecd11f to your computer and use it in GitHub Desktop.

Select an option

Save kissgyorgy/72338288574c77ecd11f to your computer and use it in GitHub Desktop.
Python: pizza calculator calculates which is bigger
#!/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
print "Első pizza területe: %s cm2" % first_area
print "Második pizza területe: %s cm2" % second_area
print
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