Python-Übungsbeispiel 81

Python 100例Python 100 Beispiele

Problem:809*??=800*??+9*??, wobei ?? eine zweistellige Zahl darstellt. 809*?? ist eine vierstellige Zahl, das Ergebnis von 8*?? ist eine zweistellige Zahl und das Ergebnis von 9*?? ist eine dreistellige Zahl. Finde die zweistellige Zahl, die durch ?? dargestellt wird, und das Ergebnis von 809*??.

Programmanalyse:Keine.

Programmquellcode:

Beispiel (Python 2.0+)

#!/usr/bin/python # -*- coding: UTF-8 -*- a = 809 for i in range(10,100): b = i * a if b >= 1000 and b <= 10000 and 8 * i < 100 and 9 * i >= 100: print b,' = 800 * ', i, ' + 9 * ', i

Ausgabe des obigen Beispiels:

9708  = 800 *  12  + 9 *  12

Python 100例Python 100 Beispiele

Andere Erweiterungen