0% found this document useful (0 votes)
8 views3 pages

Calc - Ipynb - Colaboratory

The document outlines a digital calculator project, detailing its inputs and outputs for basic arithmetic operations such as addition, subtraction, multiplication, and division. It describes the necessary inputs, including two numeric values and an operation symbol, and provides the corresponding output as a numeric result. The document also includes code snippets that implement the calculator's functionality in a programming environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Calc - Ipynb - Colaboratory

The document outlines a digital calculator project, detailing its inputs and outputs for basic arithmetic operations such as addition, subtraction, multiplication, and division. It describes the necessary inputs, including two numeric values and an operation symbol, and provides the corresponding output as a numeric result. The document also includes code snippets that implement the calculator's functionality in a programming environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

‫‪Calc.ipynb - Colaboratory‬‬ ‫‪https://colab.research.google.com/drive/1zdU_RXKyCBmTETqaOyvPt...

‬‬

‫ﻧﻣﻭﺫﺝ ﻣﺷﺭﻭﻉ ‪ :‬ﺍﻟﻌﻧﻭﺍﻥ ‪ -‬ﺍﻟﺣﺳﺎﺑﺔ ﺍﻟﺭﻗﻣﻳﺔ‬


‫ﻧﻣﻭﺫﺝ ﺍﻟﻣﺩﺧﻼﺕ ﻭ ﺍﻟﻣﺧﺭﺟﺎﺕ‬
‫‪5+3‬‬
‫ﺍﻟﻧﺎﺗﺞ ‪8.0 :‬‬

‫‪5-3‬‬
‫ﺍﻟﻧﺎﺗﺞ ‪2.0 :‬‬

‫‪5*3‬‬
‫ﺍﻟﻧﺎﺗﺞ ‪15.0 :‬‬

‫‪5/3‬‬
‫ﺍﻟﻧﺎﺗﺞ ‪1.666 :‬‬

‫‪ :‬ﺍﻟﺗﺣﻠﻳﻝ ﺍﻻﻭﻟﻲ‬
‫ﺍﻟﻣﺩﺧﻼﺕ‪ 3 :‬ﻣﺩﺧﻼﺕ‬

‫ﺍﻟﻣﺩﺧﻝ ‪ : 1‬ﻗﻳﻣﺔ ﻋﺩﺩﻳﺔ )ﻣﺛﻼ ‪(5‬‬


‫‪ �oat‬ﻧﻭﻋﻬﺎ ‪ a‬ﺍﻟﻣﺗﻐﻳﺭﺓ‬

‫ﺍﻟﻣﺩﺧﻝ ‪ : 2‬ﺭﻣﺯ ﺍﻟﻌﻣﻠﻳﺔ ﺍﻟﺣﺳﺎﺑﻳﺔ ﺍﻟﻣﻁﻠﻭﺑﺔ ﻭ ﻫﻭ ﺣﺭﻑ )ﻣﺛﻼ ‪(/ - * +‬‬


‫‪ str‬ﻧﻭﻋﻬﺎ ‪ op‬ﺍﻟﻣﺗﻐﻳﺭﺓ‬

‫ﺍﻟﻣﺩﺧﻝ ‪ : 3‬ﻗﻳﻣﺔ ﻋﺩﺩﻳﺔ )ﻣﺛﻼ ‪(3‬‬


‫‪ �oat‬ﻧﻭﻋﻬﺎ ‪ b‬ﺍﻟﻣﺗﻐﻳﺭﺓ‬

‫ﺍﻟﻣﺧﺭﺟﺎﺕ ‪ 1 :‬ﻣﺧﺭﺝ ﻓﻘﻁ‬


‫ﺍﻟﻣﺧﺭﺝ ‪ : 1‬ﻧﺎﺗﺞ ﺍﻟﻌﻣﻠﻳﺔ ﺍﻟﺣﺳﺎﺑﻳﺔ ﻭ ﻫﻭ ﻗﻳﻣﺔ ﻋﺩﺩﻳﺔ )ﻣﺛﻼ ‪(8‬‬
‫‪ �oat‬ﻧﻭﻋﻬﺎ ‪ R‬ﺍﻟﻣﺗﻐﻳﺭﺓ‬

‫ﺍﻟﻌﻼﻗﺎﺕ ﺑﻳﻥ ﺍﻟﻣﺩﺧﻼﺕ ﻭ ﺍﻟﻣﺧﺭﺟﺎﺕ‬

‫ﺍﺫﺍ ﻛﺎﻥ ﺭﻣﺯ ﺍﻟﻌﻣﻠﻳﺔ ‪1.‬‬


‫'‪op=='+‬‬
‫ﺍﺫﺍ‬
‫‪R=a+b‬‬

‫ﺍﺫﺍ ﻛﺎﻥ ﺭﻣﺯ ﺍﻟﻌﻣﻠﻳﺔ ‪2.‬‬


‫'*'==‪op‬‬

‫‪1 of 3‬‬ ‫‪5/31/2022, 7:48 PM‬‬


‫‪Calc.ipynb - Colaboratory‬‬ ‫‪https://colab.research.google.com/drive/1zdU_RXKyCBmTETqaOyvPt...‬‬

‫'*'==‪op‬‬
‫ﺍﺫﺍ‬
‫‪R=a*b‬‬

‫ﺍﺫﺍ ﻛﺎﻥ ﺭﻣﺯ ﺍﻟﻌﻣﻠﻳﺔ ‪3.‬‬


‫'‪op=='-‬‬
‫ﺍﺫﺍ‬
‫‪R=a-b‬‬

‫ﺍﺫﺍ ﻛﺎﻥ ﺭﻣﺯ ﺍﻟﻌﻣﻠﻳﺔ ‪4.‬‬


‫'‪op=='+‬‬
‫ﻭ‬
‫ﻟﻳﺳﺕ ﺻﻔﺭﺍ ‪b‬‬
‫ﺍﺫﺍ‬
‫‪R=a/b‬‬

‫ﺍﻟﻛﻭﺩ ﺍﻟﺑﺭﻣﺟﻲ ﻟﻠﻣﺷﺭﻭﻉ‬

‫‪1‬‬ ‫ﺍﻟﻤﺪﺧﻼﺕ ‪#‬‬


‫‪2‬‬ ‫)"‪ :‬ﺍﺩﺧﻞ ﺍﻟﻘﻴﻤﺔ ﺍﻟﻌﺪﺩﻳﺔ ﺍﻻﻭﻟﻰ"(‪a = input‬‬
‫‪3‬‬ ‫‪ /‬ﺍﺩﺧﻞ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ﺍﻟﺤﺴﺎﺑﻴﺔ ﺍﻟﻤﻄﻠﻮﺑﺔ ﻣﺜﻼ ‪ +‬ﺍﻭ ‪ -‬ﺍﻭ * ﺍﻭ"(‪op = input‬‬ ‫)"‪:‬‬
‫‪4‬‬ ‫)"‪ :‬ﺍﺩﺧﻞ ﺍﻟﻘﻴﻤﺔ ﺍﻟﻌﺪﺩﻳﺔ ﺍﻟﺜﺎﻧﻴﺔ"(‪b = input‬‬
‫‪5‬‬
‫‪6‬‬ ‫ﺗﻐﻴﻴﺮ ﻧﻮﻉ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻟﻠﻨﻮﻉ ﺍﻟﻤﻨﺎﺳﺐ ﻟﺤﺴﺎﺏ ﺍﻟﻤﺨﺮﺟﺎﺕ ‪#‬‬
‫‪7‬‬ ‫)‪a = float(a‬‬
‫‪8‬‬ ‫)‪b = float(b‬‬
‫‪9‬‬
‫‪10‬‬ ‫‪ +‬ﻓﻲ ﺣﺎﻝ ﻛﺎﻥ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ‪#‬‬
‫‪11‬‬ ‫‪if op=='+':‬‬
‫‪12‬‬ ‫‪R = a + b‬‬
‫‪13‬‬
‫‪14‬‬ ‫* ﻓﻲ ﺣﺎﻝ ﻛﺎﻥ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ‪#‬‬
‫‪15‬‬ ‫‪if op=='*':‬‬
‫‪16‬‬ ‫‪R = a * b‬‬
‫‪17‬‬
‫‪18‬‬ ‫‪ -‬ﻓﻲ ﺣﺎﻝ ﻛﺎﻥ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ‪#‬‬
‫‪19‬‬ ‫‪if op=='-':‬‬
‫‪20‬‬ ‫‪R = a - b‬‬
‫‪21‬‬
‫‪22‬‬ ‫‪ /‬ﻓﻲ ﺣﺎﻝ ﻛﺎﻥ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ‪#‬‬
‫‪23‬‬ ‫ﻻ ﻳﻤﻜﻦ ﺍﻟﻘﺴﻤﺔ ﻋﻠﻰ ﺻﻔﺮ ‪if op=='/' and b!=0: #‬‬

‫‪2 of 3‬‬ ‫‪5/31/2022, 7:48 PM‬‬


‫‪Calc.ipynb - Colaboratory‬‬ ‫‪https://colab.research.google.com/drive/1zdU_RXKyCBmTETqaOyvPt...‬‬

‫‪23‬‬ ‫ﻻ ﻳﻤﻜﻦ ﺍﻟﻘﺴﻤﺔ ﻋﻠﻰ ﺻﻔﺮ ‪op=='/' and b!=0: #‬‬


‫‪24‬‬ ‫‪R = a / b‬‬
‫‪25‬‬
‫ﻃﺒﺎﻋﺔ ﺍﻟﻨﺎﺗﺞ ﻛﻤﺨﺮﺝ ‪26 #‬‬
‫))‪ : " + str(R‬ﺍﻟﻨﺎﺗﺞ ﻫﻮ"(‪27 print‬‬

‫ﺍﺩﺧﻞ ﺍﻟﻘﻴﻤﺔ ﺍﻟﻌﺪﺩﻳﺔ ﺍﻻﻭﻟﻰ ‪5:‬‬


‫‪ /‬ﺍﺩﺧﻞ ﺭﻣﺰ ﺍﻟﻌﻤﻠﻴﺔ ﺍﻟﺤﺴﺎﺑﻴﺔ ﺍﻟﻤﻄﻠﻮﺑﺔ ﻣﺜﻼ ‪ +‬ﺍﻭ ‪ -‬ﺍﻭ * ﺍﻭ‬ ‫‪:/‬‬
‫ﺍﺩﺧﻞ ﺍﻟﻘﻴﻤﺔ ﺍﻟﻌﺪﺩﻳﺔ ﺍﻟﺜﺎﻧﻴﺔ ‪3:‬‬
‫ﺍﻟﻨﺎﺗﺞ ﻫﻮ ‪1.6666666666666667 :‬‬

‫‪3 of 3‬‬ ‫‪5/31/2022, 7:48 PM‬‬

You might also like