SlideShare una empresa de Scribd logo
1 de 14
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour
The Math Object In this lesson, you will learn about: Using different operations of the Math object. Using different properties of the Math object.
The Math Object The Math object offers many mathematical functions that you can use in your programs. It includes various operations and properties, such as: Do complex mathematical calculations boggle your mind at times?  Don’t worry!  ,[object Object]
 GetRandomNumber
 Sin
 SquareRoot
 Remainder
 Pi
 Abs
ArcSin
 Floor
GetDegrees
 Log
 Min,[object Object]

Más contenido relacionado

La actualidad más candente

Data structures and algorithms lab9
Data structures and algorithms lab9Data structures and algorithms lab9
Data structures and algorithms lab9
Bianca Teşilă
 
Using visual basic for applications (vba)
Using visual basic for applications (vba)Using visual basic for applications (vba)
Using visual basic for applications (vba)
Javier Morales Cauna
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
irdginfo
 

La actualidad más candente (19)

Data structures and algorithms lab9
Data structures and algorithms lab9Data structures and algorithms lab9
Data structures and algorithms lab9
 
Stack application
Stack applicationStack application
Stack application
 
Write a Java program Lab42.java: implement a superclass Account with the prot...
Write a Java program Lab42.java: implement a superclass Account with the prot...Write a Java program Lab42.java: implement a superclass Account with the prot...
Write a Java program Lab42.java: implement a superclass Account with the prot...
 
Intelligent Digit Recognition Engine: Architecture
Intelligent Digit Recognition Engine: ArchitectureIntelligent Digit Recognition Engine: Architecture
Intelligent Digit Recognition Engine: Architecture
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
 
Using visual basic for applications (vba)
Using visual basic for applications (vba)Using visual basic for applications (vba)
Using visual basic for applications (vba)
 
House price prediction
House price predictionHouse price prediction
House price prediction
 
Tech Talk - JPA and Query Optimization - publish
Tech Talk  -  JPA and Query Optimization - publishTech Talk  -  JPA and Query Optimization - publish
Tech Talk - JPA and Query Optimization - publish
 
For next
For nextFor next
For next
 
Topology in ArcGIS
Topology in ArcGISTopology in ArcGIS
Topology in ArcGIS
 
Function BPK2
Function BPK2Function BPK2
Function BPK2
 
Greedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.pptGreedy with Task Scheduling Algorithm.ppt
Greedy with Task Scheduling Algorithm.ppt
 
Object Oriented Programming Assignment 3
Object Oriented Programming Assignment 3Object Oriented Programming Assignment 3
Object Oriented Programming Assignment 3
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Object Oriented Programming Assignment 2
Object Oriented Programming Assignment 2Object Oriented Programming Assignment 2
Object Oriented Programming Assignment 2
 
Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4Object Oriented Programming Assignment 4
Object Oriented Programming Assignment 4
 
Using IPython to Find Correlation
Using IPython to Find CorrelationUsing IPython to Find Correlation
Using IPython to Find Correlation
 
Scaling in R
Scaling in RScaling in R
Scaling in R
 
Ecet 370 week 2 lab 2
Ecet 370 week 2 lab 2Ecet 370 week 2 lab 2
Ecet 370 week 2 lab 2
 

Destacado (6)

3.6 debugging aids
3.6   debugging aids3.6   debugging aids
3.6 debugging aids
 
4.1 playing with shapes
4.1   playing with shapes4.1   playing with shapes
4.1 playing with shapes
 
4.2 responding to events
4.2   responding to events4.2   responding to events
4.2 responding to events
 
4.4 advanced games
4.4   advanced games4.4   advanced games
4.4 advanced games
 
5.1 sharing code
5.1   sharing code5.1   sharing code
5.1 sharing code
 
Mlp_winter-2015
Mlp_winter-2015Mlp_winter-2015
Mlp_winter-2015
 

Similar a 3.3 the math object

Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
leventhalbrad49439
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
tiffanyd4
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
Miles Ford
 

Similar a 3.3 the math object (20)

3.3 - The Math Object.pptx
3.3 - The Math Object.pptx3.3 - The Math Object.pptx
3.3 - The Math Object.pptx
 
Data Transformation
Data TransformationData Transformation
Data Transformation
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
 
5. R basics
5. R basics5. R basics
5. R basics
 
Recursion | C++ | DSA
Recursion | C++ | DSARecursion | C++ | DSA
Recursion | C++ | DSA
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Scilab as a calculator
Scilab as a calculatorScilab as a calculator
Scilab as a calculator
 
Course project solutions 2018
Course project solutions 2018Course project solutions 2018
Course project solutions 2018
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
 
Interview questions slide deck
Interview questions slide deckInterview questions slide deck
Interview questions slide deck
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Scientific calculator project in c language
Scientific calculator project in c languageScientific calculator project in c language
Scientific calculator project in c language
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
 

Más de allenbailey

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
allenbailey
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
allenbailey
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
allenbailey
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
allenbailey
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
allenbailey
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
allenbailey
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
allenbailey
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
allenbailey
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
allenbailey
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
allenbailey
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
allenbailey
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
allenbailey
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
allenbailey
 

Más de allenbailey (14)

4.3 collision detection
4.3   collision detection4.3   collision detection
4.3 collision detection
 
3.4 events and interactivity
3.4   events and interactivity3.4   events and interactivity
3.4 events and interactivity
 
3.1 file input and output
3.1   file input and output3.1   file input and output
3.1 file input and output
 
2.6 flickr, image list, and network objects
2.6   flickr, image list, and network objects2.6   flickr, image list, and network objects
2.6 flickr, image list, and network objects
 
2.5 clock, desktop, and dictionary objects
2.5   clock, desktop, and dictionary objects2.5   clock, desktop, and dictionary objects
2.5 clock, desktop, and dictionary objects
 
2.4 sound, program, and text objects
2.4   sound, program, and text objects2.4   sound, program, and text objects
2.4 sound, program, and text objects
 
2.3 exploring shapes
2.3   exploring shapes2.3   exploring shapes
2.3 exploring shapes
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
2.1 graphics window
2.1   graphics window2.1   graphics window
2.1 graphics window
 
1.5 branching and subroutines
1.5   branching and subroutines1.5   branching and subroutines
1.5 branching and subroutines
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
1.3 variables
1.3   variables1.3   variables
1.3 variables
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
1.1 introduction to small basic
1.1   introduction to small basic1.1   introduction to small basic
1.1 introduction to small basic
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

3.3 the math object

  • 1. Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour
  • 2. The Math Object In this lesson, you will learn about: Using different operations of the Math object. Using different properties of the Math object.
  • 3.
  • 14.
  • 15. The Pi Property The value of pi is an important aspect of some mathematical calculations. You can use the Pi property of the Math object to retrieve the value of pi in your calculations. Let’s use this property to calculate the area of the circle. output In this example, you use the Pi property of the Math object to retrieve the value of pi. Then you use this value in the formula to get the area of the circle.
  • 16. The Abs Operation Abs is another useful operation provided by the Math object. Let’s check it out. With the help of the Abs operation, you can get the absolute value of the given number. For example, if you subtract a large number from a smaller number, it will result in a negative numeral. In this example, you subtract two numbers. If the first number is smaller than the second, Abs operation returns a positive number.
  • 17. The Floor Operation While creating your Small Basic program, how can you get the integer value of a decimal number?  That’s what the Floor operation is created for. It gives an integer value which is less than or equal to the specified decimal number. Let’s see how you can use this operation in a program to calculate a student’s average grade. In this example, you enter the grades received by a student in six subjects. Then, you use the Floor operation to get the student’s average as an integer value.
  • 18. The Log Operation While doing complex calculations, you often need the log value of a particular number. The Math object in Small Basic offers the Log operation to get the logarithm (base 10) value of the specified number. In this example, you use the Log operation to get the log of 22.3.
  • 19. The GetRandomNumber Operation Now, let’s discuss the GetRandomNumber operation of the Math object.  You can use this operation to get a random number between 1 and the specified maximum number. Let’s use this operation in a program. In this program, you draw the ‘*’ shape on the graphics window in different sizes and at different locations.   You first set the height, width, and background color of the graphics window. Then you use the GetRandomNumber operation to set the font size. The font size will be between 1 and 30 because you have specified 30 as the parameter for the GetRandomNumber operation.   Next, you use this operation to set the x- and y-coordinates of the asterisks at random.
  • 20. The Min Operation The Math object provides another operation called the Min operation. You can use this operation to compare two numbers and get the smaller number of the two. Let’s apply this operation in a program. In this example, you accept two numbers and use the Min operation to compare the two numbers and display the smaller number in the text window. You also ensure that if the entered numbers are equal, the text window displays the statement “These numbers are the same.”
  • 21. The SquareRoot Operation Let’s check out the SquareRoot operation of the Math object. You can use this operation to get the square root of a specified number. In this example, you enter a number and use the SquareRoot operation to get its square root.
  • 22. The Remainder Operation Let’s look at the Remainder operation of the Math object. You can use this operation to get the remainder in a division problem. In this program, you want to check whether a number is even or odd. You use the If condition to check if the entered number is completely divisible by 2 (the remainder is 0). If so, the number is an even number; otherwise, it is an odd number. To check the remainder, you use the Remainder operation of the Math object.
  • 23. Let’s Summarize… Congratulations! Now you know how to: Use different properties of the Math object. Use different operations of the Math object.
  • 24. It’s Time to Apply Your Learning… Write a program to draw circles of different sizes in the graphics window. Set the size of the circle by using the area of the circle and randomize the x- and y- coordinates of the circle. Using the GetRandomNumber operation, write a program to move and rotate a rectangle in a random manner.

Notas del editor

  1. Slide Notes:You can use the Sin operation to get the sine of the specified angle in radians.You can use the ArcSin operation to get the angle in radians, given the sin value.You can use the GetDegrees operation to convert the value of an angle from radians to degrees.You can use the Cos operation to get the cosine of the specified angle in radians.Code:TextWindow.WriteLine("Enter the angle in degrees and get the sine of the angle:")number = TextWindow.Read()TextWindow.WriteLine("The sine of the angle is " + Math.Sin(number))TextWindow.WriteLine("The arcsine of the angle is " + Math.ArcSin(Math.Sin(number)))TextWindow.WriteLine("The angle in degrees is " + Math.GetDegrees(Math.ArcSin(Math.Sin(number))))TextWindow.WriteLine("Enter the angle in degrees and get the cosine of the angle:")number = TextWindow.Read()TextWindow.WriteLine("The cosine of the angle is " + Math.Cos(number))
  2. SlideNotes: The Pi property of the Math object returns the value of pi, which is 3.14.Code:TextWindow.Write("Enter radius of a circle:")Radius = TextWindow.Read()Area = Math.Pi * Math.Power(Radius, 2)TextWindow.WriteLine("Area of the Circle is " + Area) 
  3. Notes:You can use the Abs operation of the Math object to get the absolute value of a number. For example, if the given number is -50, the Abs operation will return the value as 50.Code:TextWindow.WriteLine("Enter two numbers for subtraction: ")Number1 = TextWindow.Read()Number2 = TextWindow.Read()Substraction = Number1 - Number2Textwindow.WriteLine("The answer is " + Math.Abs(substraction))
  4. Code:TextWindow.Write("Enter the name of the student: ")Name = TextWindow.Read()TextWindow.WriteLine("Enter the student's marks in six subjects:")For I = 0 To 5 Subject[i] = TextWindow.Read() Total = Total + Subject[i]EndForPercentage = Total / 6TextWindow.WriteLine("Total Marks:" + Total)TextWindow.WriteLine("Percentage:" + Math.Floor(percentage))
  5. Code:TextWindow.WriteLine("Enter number to get its log value: ")Number = TextWindow.Read()TextWindow.WriteLine("Log value of " + Number + " is: " + Math.Log(Number))
  6. Code:GraphicsWindow.BackgroundColor = "Black"GraphicsWindow.Width = 600GraphicsWindow.Height = 500For i = 0 To 800GraphicsWindow.FontSize = Math.GetRandomNumber(30) x = Math.GetRandomNumber(GraphicsWindow.Width) y = Math.GetRandomNumber(GraphicsWindow.Height)GraphicsWindow.DrawText(x, y, "*")Program.Delay(10)EndFor
  7. Code:TextWindow.WriteLine("Enter the first number:")Number1 = TextWindow.Read()TextWindow.WriteLine("Enter the second number:")Number2 = TextWindow.Read()min = Math.Min(Number1, Number2)If (Number1 = Number2) ThenTextWindow.WriteLine(“These numbers are the same")Else TextWindow.WriteLine("The smaller number is:" + min) EndIf
  8. Code:TextWindow.Write("Enter a number to get its square root: ")Number = TextWindow.Read()TextWindow.WriteLine("Square root of the entered number is " + Math.SquareRoot(Number))
  9. Code:start:TextWindow.Write("Enter a number to check if it is even or odd: ")number = TextWindow.Read()If Math.Remainder(number, 2) = 0 ThenTextWindow.WriteLine(number + " is an even number.")ElseTextWindow.WriteLine(number + " is an odd number.")EndIfGoto start
  10. Solution 1:Rectangle = Shapes.AddRectangle(100, 100)Shapes.Move(Rectangle, 250, 150)For i = 0 To Math.GetRandomNumber(30) Program.Delay(500)Shapes.Rotate(Rectangle, i * 25) EndForSolution 2:start:GraphicsWindow.Width = 600GraphicsWindow.Height = 450TextWindow.Write("Enter a radius for the circle: ")Radius = TextWindow.Read()Area = Math.Pi * Radius * RadiusHeight = Area / 2Width = Area / 2x = Math.GetRandomNumber(GraphicsWindow.Width / 2)y = Math.GetRandomNumber(GraphicsWindow.Height / 2)GraphicsWindow.DrawEllipse(x, y, Height, Width)Goto start