Helpful Functions for Iris Species Prediction and Dot Number Calculation

Slide Note
Embed
Share

The provided content includes a function to predict Iris species based on petal length and width (Iris setosa, Iris versicolor, Iris virginica) and a function to calculate the number of dots in a figure pattern. The Iris prediction function uses specific criteria for each species, and the dot number calculation follows a general expression formula. Explore these functions for practical applications in species identification and mathematical pattern recognition.


Uploaded on Sep 18, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. 1. Three plant species from the Iris family, Iris setosa, Iris versicolor and Iris virginica, can be distinguished by the petal length and petal width. Write a function that, when given a petal length and width, predicts the Iris species. Example: predict(1.4, 0.2) >>> Iris setosa

  2. 1. Three plant species from the Iris family, Iris setosa, Iris versicolor and Iris virginica, can be distinguished by the petal length and petal width.

  3. 1. Three plant species from the Iris family, Iris setosa, Iris versicolor and Iris virginica, can be distinguished by the petal length and petal width. def predict(length, width): prediction = '' if 0.8>width>0: if 2>length>0.9: prediction +='Iris setosa ' if 1.8>width>0.8: if 5.5>length>2.5: prediction +='Iris versicolor ' if 2.6>width>1.2: if 7>length>4: prediction +='Iris virginica' return prediction

  4. 2. Study the dot number in these figures to arrive at a general expression of the dot number. For example, how many dots would Figure 30 contain? Write a function that accepts the figure number and returns the number of dots.

  5. 2. Study the dot number in these figures to arrive at a general expression of the dot number. For example, how many dots would Figure 30 contain? Write a function that accepts the figure number and returns the number of dots. Figure Number of dots Pattern 1 10 - 2 16 10 + 6 3 22 10 + 6 + 6 4 28 10 + 6 + 6 + 6 .. General expression: 10 + (n - 1) * 6

  6. 2. Study the dot number in these figures to arrive at a general expression of the dot number. For example, how many dots would Figure 30 contain? Write a function that accepts the figure number and returns the number of dots. Figure Number of dots Pattern 1 10 - 2 16 10 + 6 3 22 10 + 6 + 6 4 28 10 + 6 + 6 + 6 .. General expression: 10 + (n - 1) * 6 def dotNum(figure): return(10 + (figure - 1) * 6)

Related


More Related Content