Skip to content

Commit 2a75a50

Browse files
committed
Created using Colab
1 parent df67739 commit 2a75a50

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

R_Programming_Language.ipynb

+65-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"nbformat_minor": 0,
44
"metadata": {
55
"colab": {
6-
"provenance": []
6+
"provenance": [],
7+
"toc_visible": true,
8+
"authorship_tag": "ABX9TyPtpKv2dvb2tqFiJtCT2hTt",
9+
"include_colab_link": true
710
},
811
"kernelspec": {
912
"name": "ir",
@@ -14,6 +17,16 @@
1417
}
1518
},
1619
"cells": [
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {
23+
"id": "view-in-github",
24+
"colab_type": "text"
25+
},
26+
"source": [
27+
"<a href=\"https://colab.research.google.com/github/jsdhami/R-Programming-for-Beginners/blob/main/R_Programming_Language.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
28+
]
29+
},
1730
{
1831
"cell_type": "markdown",
1932
"source": [
@@ -10652,6 +10665,57 @@
1065210665
}
1065310666
]
1065410667
},
10668+
{
10669+
"cell_type": "code",
10670+
"source": [
10671+
"# Calculator\n",
10672+
"\n",
10673+
"a <- as.numeric(readline(prompt = \"Enter First Number: \"))\n",
10674+
"b <- as.numeric(readline(prompt = \"Enter Second Number: \"))\n",
10675+
"cat(\"What do you want?\\n\")\n",
10676+
"cat(\"1. Sum\\n\")\n",
10677+
"cat(\"2. Subtract\\n\")\n",
10678+
"cat(\"3. Divide\\n\")\n",
10679+
"p <- as.numeric(readline(prompt = \"Choose one (1, 2, 3): \"))\n",
10680+
"\n",
10681+
"result <- switch(p,\n",
10682+
" `1` = a + b,\n",
10683+
" `2` = a - b,\n",
10684+
" `3` = ifelse(b != 0, a / b, \"Error: Division by zero\"),\n",
10685+
" \"Invalid choice\"\n",
10686+
")\n",
10687+
"\n",
10688+
"if (is.numeric(result)) {\n",
10689+
" cat(\"The result is:\", result, \"\\n\")\n",
10690+
"} else {\n",
10691+
" cat(result, \"\\n\")\n",
10692+
"}\n"
10693+
],
10694+
"metadata": {
10695+
"colab": {
10696+
"base_uri": "https://localhost:8080/"
10697+
},
10698+
"id": "z7Q7r7J0ePeo",
10699+
"outputId": "60c1011d-b9ae-4f1b-dc1b-8f14fb183f63"
10700+
},
10701+
"execution_count": null,
10702+
"outputs": [
10703+
{
10704+
"output_type": "stream",
10705+
"name": "stdout",
10706+
"text": [
10707+
"Enter First Number: 436\n",
10708+
"Enter Second Number: 54645\n",
10709+
"What do you want?\n",
10710+
"1. Sum\n",
10711+
"2. Subtract\n",
10712+
"3. Divide\n",
10713+
"Choose one (1, 2, 3): 1\n",
10714+
"The result is: 55081 \n"
10715+
]
10716+
}
10717+
]
10718+
},
1065510719
{
1065610720
"cell_type": "markdown",
1065710721
"source": [

0 commit comments

Comments
 (0)