尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
PROGRAMMING
IN
LUA
(if –else/if-elseif/while loop/nested
while loop)
INDEX
1 Program to accept the number from user and check it’s a palindrome or not
2 Program to accept the number from user and check it’s an ARMSTRONG or not.
3 Program to accept the decimal number from user and display its binary number
4 Program to accept the binary number from user and display its decimal number
5 program to print series 0,3,8,15,24,35,48,63,80,99....N
6
program to print output as given
1
12
123
1234
12345
7
program to print output as given
1
121
12321
1234321
123454321
8 Program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55
9 Program to create Simple Calculator(+,-,*,/)
10 Program to Check the year is a Leap Year or not
11 Program to Compute Sum of Series1+ x2
/3! + x3
/5! + x4
/3! + x5
/4! + .. + xn
/2n-1!
--[[Program to accept the number from user and check it’s a palindrome or not.]]--
no=0
tmp=0
oldval=0
print("Enter the number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp*10+x
no=math.floor(no/10)
end
if(tmp == oldval)
then
io.write("It’s a palindrome")
else
io.write("It’s a not palindrome")
end
-------------------output------------------
Enter the number
1221
It’s a palindrome
--[[Program to accept the number from user and check its a ARMSTRONG or not.]]--
no=0
tmp=0
oldval=0
print("Enter the number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp+x^3
no=math.floor(no/10)
end
if(tmp == oldval)
then
io.write("Its a armstrong")
else
io.write("Its a not a armstrong")
end
-------------------output------------------
Enter the number
153
It’s an Armstrong
--[[Program to accept the decimal number from user and display its binary number]]--
no=0
tmp=0
oldval=0
print("Enter the decimal number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%2)
tmp=tmp*10+x
no=math.floor(no/2)
end
no=tmp
tmp=0
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp*10+x
no=math.floor(no/10)
end
print("binary of "..oldval.."= "..tmp)
--------------------output--------------------------
Enter the decimal number
23
binary of 23= 10111
--[[Program to accept the binary number from user and display its decimal number]]--
no=0
tmp=0
oldval=0
a=0
print("Enter the binary number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp+(x*2^a)
no=math.floor(no/10)
a=a+1
end
print("Decimal of "..oldval.."= "..tmp)
------------------------output------------------
Enter the binary number
10111
Decimal of 10111= 23
--[[program to print series 0,3,8,15,24,35,48,63,80,99....N]]--
N=0
tmp=0
a=0
a1=0
x=0
print("Enter the value of N")
N=tonumber(io.read())
while(x<=N)
do
tmp=x+a
io.write(tmp..",")
x=x+1
a1=a1+2
a=a+a1
end
--[[program to print Pentagonal number Series 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176]]—
N=0
tmp=0
print("Enter the value of N")
N=tonumber(io.read())
x=0
while(x<=N)
do
tmp=(3*x*x-x)/2
io.write(tmp..",")
x=x+1
end
------------------output--------------------
Enter the value of N
10
0,1,5,12,22,35,51,70,92,117,145
--[[program to print output as given
1
12
123
1234
12345
]]--
x=1
k=4
while(x<=5)
do
a=1
while(a<=k)
do
io.write(" ")
a=a+1
end
k=k-1
y=1
while(y<=x)
do
io.write(y)
y=y+1
end
print()
x=x+1
end
--[[program to print output as given
1
121
12321
1234321
123454321
]]--
x=1
k=4
while(x<=5)
do
a=1
while(a<=k)
do
io.write(" ")
a=a+1
end
k=k-1
y=1
while(y<=x)
do
io.write(y)
y=y+1
end
z=x-1
while(z>=1)
do
io.write(z)
z=z-1
end
print()
x=x+1
end
--[[program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55]]--
x=1
insum=0
outsum=0
while(x<=5)
do
y=1
insum=0
io.write("(")
while(y<=x)
do
insum=insum+x
io.write(y.."+")
y=y+1
end
io.write("b)+")
outsum=outsum+insum
x=x+1
end
print("b="..outsum)
--[[ Program to create Simple Calculator(+,-,*,/) ]]--
ch=' '
op1=0
op2=0
print("Enter the op1 and op2")
op1=tonumber(io.read())
op2=tonumber(io.read())
print("Enter the operator(+,-,/,*)")
ch=io.read()
if(ch=="+")
then
print(op1.."+"..op2.."="..(op1+op2))
elseif(ch=="-")
then
print(op1.."-"..op2.."="..(op1-op2))
elseif(ch=="/")
then
print(op1.."/"..op2.."="..(op1/op2))
elseif(ch=="*")
then
print(op1.."*"..op2.."="..(op1*op2))
else
print("invalid operator")
end
----------------------output----------------------
Enter the op1 and op2
10
20
Enter the operator(+,-,/,*)
+
10+20=30
--[[Program to Check Leap Year]]--
yy=0
print("Enter the year")
yy=tonumber(io.read())
if(yy%100 == 0 or yy%4==0 or yy%400==0)
then
print("its a leap year")
else
print("its not a leap year")
end
---------------------output----------------------
Enter the year
1988
its a leap year
--[[Program to Compute Sum of Series 1 + x2/3! + x3/5! + x4/3! + x5/4! + .. + xn/2n-1!]]--
sum=1.00
a=2
fact=1
y=0
print("Enter the value of x,N")
x=tonumber(io.read())
N=tonumber(io.read())
while(a<=N)
do
tmp=x^a
fact=1
y=2*a-1
while(y>=1)
do
fact=fact*y
y=y-1
end
sum = sum +tmp/fact
a=a+1
end
print("sum="..sum)
-------------------output-------------------------
Enter the value of x,N 2 10
sum=1.7365977440172

More Related Content

What's hot

week-11x
week-11xweek-11x
C programs
C programsC programs
C programs
Minu S
 
Applied numerical methods lec2
Applied numerical methods lec2Applied numerical methods lec2
Applied numerical methods lec2
Yasser Ahmed
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
Farhan Ab Rahman
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
Operating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - EngineeringOperating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - Engineering
Yogesh Santhan
 
Public class arithmetic operatordemo
Public class arithmetic operatordemoPublic class arithmetic operatordemo
Public class arithmetic operatordemo
Cliff Rodrigo
 
Dsp lab task 2
Dsp lab task 2Dsp lab task 2
Dsp lab task 2
ChetanShahukari
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
Tony Kurishingal
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
Norhan Mohamed
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
alish sha
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
Csci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingCsci101 lect06 advanced_looping
Csci101 lect06 advanced_looping
Elsayed Hemayed
 
week-4x
week-4xweek-4x
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
One97 Communications Limited
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
.Cpp
.Cpp.Cpp

What's hot (20)

week-11x
week-11xweek-11x
week-11x
 
C programs
C programsC programs
C programs
 
Applied numerical methods lec2
Applied numerical methods lec2Applied numerical methods lec2
Applied numerical methods lec2
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Operating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - EngineeringOperating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - Engineering
 
Public class arithmetic operatordemo
Public class arithmetic operatordemoPublic class arithmetic operatordemo
Public class arithmetic operatordemo
 
Dsp lab task 2
Dsp lab task 2Dsp lab task 2
Dsp lab task 2
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Csci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingCsci101 lect06 advanced_looping
Csci101 lect06 advanced_looping
 
week-4x
week-4xweek-4x
week-4x
 
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
.Cpp
.Cpp.Cpp
.Cpp
 

Similar to Programming in lua Basic

Loops in Python
Loops in PythonLoops in Python
Loops in Python
Arockia Abins
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
YashMirge2
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
Mahyuddin8
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Sheila Sinclair
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
vikram mahendra
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
JaswinderKaurSarao
 
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
DHANUSHTEJVUNNAM
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
paijitk
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
vineetdhand2004
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
SulbhaGath1
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
SulbhaGath1
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
SulbhaGath1
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
BG Java EE Course
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
Talk Code
Talk CodeTalk Code
Talk Code
Agiliq Solutions
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
ssuser476810
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
ysolanki78
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 

Similar to Programming in lua Basic (20)

Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
 
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
 
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Talk Code
Talk CodeTalk Code
Talk Code
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 

More from vikram mahendra

Communication skill
Communication skillCommunication skill
Communication skill
vikram mahendra
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
vikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
vikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
vikram mahendra
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
vikram mahendra
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
vikram mahendra
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
vikram mahendra
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
vikram mahendra
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
vikram mahendra
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
vikram mahendra
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
vikram mahendra
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
vikram mahendra
 

More from vikram mahendra (20)

Communication skill
Communication skillCommunication skill
Communication skill
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
 

Recently uploaded

Solar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdfSolar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdf
SERVE WELL CRM NASHIK
 
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdfThe Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
kalichargn70th171
 
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Anita pandey
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
aneeshmanikantan2341
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
meenusingh4354543
 
NLJUG speaker academy 2024 - session 1, June 2024
NLJUG speaker academy 2024 - session 1, June 2024NLJUG speaker academy 2024 - session 1, June 2024
NLJUG speaker academy 2024 - session 1, June 2024
Bert Jan Schrijver
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
manji sharman06
 
Folding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a seriesFolding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a series
Philip Schwarz
 
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
ns9201415
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
Chad Crowell
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
Staff AgentAI
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Ortus Solutions, Corp
 
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable PriceCall Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
vickythakur209464
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Alberto Brandolini
 
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
Shane Coughlan
 

Recently uploaded (20)

Solar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdfSolar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdf
 
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdfThe Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
 
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
 
NLJUG speaker academy 2024 - session 1, June 2024
NLJUG speaker academy 2024 - session 1, June 2024NLJUG speaker academy 2024 - session 1, June 2024
NLJUG speaker academy 2024 - session 1, June 2024
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
 
Folding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a seriesFolding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a series
 
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
Hot Call Girls In Ahmedabad ✔ 7737669865 ✔ Hi I Am Divya Vip Call Girl Servic...
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
Happy Birthday Kubernetes, 10th Birthday edition of Kubernetes Birthday in Au...
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
 
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable PriceCall Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
 
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
 

Programming in lua Basic

  • 2. INDEX 1 Program to accept the number from user and check it’s a palindrome or not 2 Program to accept the number from user and check it’s an ARMSTRONG or not. 3 Program to accept the decimal number from user and display its binary number 4 Program to accept the binary number from user and display its decimal number 5 program to print series 0,3,8,15,24,35,48,63,80,99....N 6 program to print output as given 1 12 123 1234 12345 7 program to print output as given 1 121 12321 1234321 123454321 8 Program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55 9 Program to create Simple Calculator(+,-,*,/) 10 Program to Check the year is a Leap Year or not 11 Program to Compute Sum of Series1+ x2 /3! + x3 /5! + x4 /3! + x5 /4! + .. + xn /2n-1!
  • 3. --[[Program to accept the number from user and check it’s a palindrome or not.]]-- no=0 tmp=0 oldval=0 print("Enter the number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp*10+x no=math.floor(no/10) end if(tmp == oldval) then io.write("It’s a palindrome") else io.write("It’s a not palindrome") end -------------------output------------------ Enter the number 1221 It’s a palindrome
  • 4. --[[Program to accept the number from user and check its a ARMSTRONG or not.]]-- no=0 tmp=0 oldval=0 print("Enter the number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp+x^3 no=math.floor(no/10) end if(tmp == oldval) then io.write("Its a armstrong") else io.write("Its a not a armstrong") end -------------------output------------------ Enter the number 153 It’s an Armstrong
  • 5. --[[Program to accept the decimal number from user and display its binary number]]-- no=0 tmp=0 oldval=0 print("Enter the decimal number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%2) tmp=tmp*10+x no=math.floor(no/2) end no=tmp tmp=0 while(no ~= 0) do x=math.floor(no%10) tmp=tmp*10+x no=math.floor(no/10) end print("binary of "..oldval.."= "..tmp) --------------------output-------------------------- Enter the decimal number 23 binary of 23= 10111
  • 6. --[[Program to accept the binary number from user and display its decimal number]]-- no=0 tmp=0 oldval=0 a=0 print("Enter the binary number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp+(x*2^a) no=math.floor(no/10) a=a+1 end print("Decimal of "..oldval.."= "..tmp) ------------------------output------------------ Enter the binary number 10111 Decimal of 10111= 23
  • 7. --[[program to print series 0,3,8,15,24,35,48,63,80,99....N]]-- N=0 tmp=0 a=0 a1=0 x=0 print("Enter the value of N") N=tonumber(io.read()) while(x<=N) do tmp=x+a io.write(tmp..",") x=x+1 a1=a1+2 a=a+a1 end
  • 8. --[[program to print Pentagonal number Series 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176]]— N=0 tmp=0 print("Enter the value of N") N=tonumber(io.read()) x=0 while(x<=N) do tmp=(3*x*x-x)/2 io.write(tmp..",") x=x+1 end ------------------output-------------------- Enter the value of N 10 0,1,5,12,22,35,51,70,92,117,145
  • 9. --[[program to print output as given 1 12 123 1234 12345 ]]-- x=1 k=4 while(x<=5) do a=1 while(a<=k) do io.write(" ") a=a+1 end k=k-1 y=1 while(y<=x) do io.write(y) y=y+1 end print() x=x+1 end
  • 10. --[[program to print output as given 1 121 12321 1234321 123454321 ]]-- x=1 k=4 while(x<=5) do a=1 while(a<=k) do io.write(" ") a=a+1 end k=k-1 y=1 while(y<=x) do io.write(y) y=y+1 end z=x-1 while(z>=1) do io.write(z) z=z-1 end print() x=x+1 end
  • 11. --[[program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55]]-- x=1 insum=0 outsum=0 while(x<=5) do y=1 insum=0 io.write("(") while(y<=x) do insum=insum+x io.write(y.."+") y=y+1 end io.write("b)+") outsum=outsum+insum x=x+1 end print("b="..outsum)
  • 12. --[[ Program to create Simple Calculator(+,-,*,/) ]]-- ch=' ' op1=0 op2=0 print("Enter the op1 and op2") op1=tonumber(io.read()) op2=tonumber(io.read()) print("Enter the operator(+,-,/,*)") ch=io.read() if(ch=="+") then print(op1.."+"..op2.."="..(op1+op2)) elseif(ch=="-") then print(op1.."-"..op2.."="..(op1-op2)) elseif(ch=="/") then print(op1.."/"..op2.."="..(op1/op2)) elseif(ch=="*") then print(op1.."*"..op2.."="..(op1*op2)) else print("invalid operator") end ----------------------output---------------------- Enter the op1 and op2 10 20 Enter the operator(+,-,/,*) + 10+20=30
  • 13. --[[Program to Check Leap Year]]-- yy=0 print("Enter the year") yy=tonumber(io.read()) if(yy%100 == 0 or yy%4==0 or yy%400==0) then print("its a leap year") else print("its not a leap year") end ---------------------output---------------------- Enter the year 1988 its a leap year
  • 14. --[[Program to Compute Sum of Series 1 + x2/3! + x3/5! + x4/3! + x5/4! + .. + xn/2n-1!]]-- sum=1.00 a=2 fact=1 y=0 print("Enter the value of x,N") x=tonumber(io.read()) N=tonumber(io.read()) while(a<=N) do tmp=x^a fact=1 y=2*a-1 while(y>=1) do fact=fact*y y=y-1 end sum = sum +tmp/fact a=a+1 end print("sum="..sum) -------------------output------------------------- Enter the value of x,N 2 10 sum=1.7365977440172
  翻译: