Convert hejri year to calendar year and vice vers ça

program 1 : convert hejri year to calendar year

import os         
def hejri_calen():
    h_year = 0
    c_year = 0
    h_year = raw_input("write a hejri year")
    c_year = (int(h_year) + 622) - (int(h_year)/33)
    print(c_year)
# test de la fonction calen_hejri
if __name__ == "__main__":
    hejri_calen()
    os.system("pause")

program 2 convert calendar year to hejri year

import os
def calen_hejri():
    h_year = 0
    c_year = 0
    c_year = raw_input("write a calendar year")
    h_year = (int(c_year) - 622)/0.97
    print(h_year)
#calen_hejri()
# test de la fonction calen_hejri
if __name__ == "__main__":
    calen_hejri()
    os.system("pause")

I’m doing an executable of the program2 using sublime text3 and cx_Freeze

it can works without needing to download python

https://drive.google.com/file/d/1NV4nj0_75fyvAOc1roRY11p8qfuSSyks/view?usp=sharing

noun of file is: calen-hejri
try it please

Note : when we have a problem to execute our program in sublime text we can use the module os to create a pause. it helps us to see the output of our code. And we can run our code with double click on it

import os # import of module os

our code 

    os.system("pause") #system pause

Here I created an integrate module to test the execution of the program

# test de la fonction calen_hejri
if __name__ == "__main__":
    hejri_calen()
5 Likes

بعض الشرح لو سمحت :joy::ok_hand:

1 Like

بعض الأسئلة لو سمحت :grin:

1 Like

فقط احتاج فهم فكره التحويل والفرق بين التقويمين

1 Like

الفانكشن الأولى تقوم بتحويل سنة هجرية الى سنة ميلادية
اطلب في البداية ادخال سنة هجرية باستعمال
raw_input
ثم اقوم بتحويلها عن طريق عملية حسابية بحثت عنها على google
و اخيرا قمت باستدعاء الفانكشن بصنع module عن طريق خاصية
if name …

1 Like

اهاااا
المعادله هي م لفت نظري

1 Like

الفانكشن الثانية نفس الطريقة
لكن طريقة الحساب تختلف قليلا و قد وجدتها أيضا على google
كما قمت بصنع executable لهذا البرنامج الثاني حتى يتسنى لمن ليس له بايثون ان يفتحه و يشغله بما أن ال executable يحمل معه كل مكتبات البايثون.
استعملت في هذا برنامج cx-Freeze
سأقوم بانزال موضوع حول كيفية القيام بهذا بالتفصيل حين أجد الوقت لذلك

1 Like

أنا أعجبتني الفكرة ككل لأنها فكرتي :grin: و رغم بساطة الكود إلا أني سعيدة بهذا
طبعا ينقصها الكثير كإضافة احتمالات الخطأ أو غيرها من التفاصيل

1 Like