1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nadya68 [22]
4 years ago
10

Write a function (named n_pointed_star) to make the turtle draw an n-pointed star. The function should return nothing, and accep

t a single parameter (n_points) which specifies the number of points to draw.
Computers and Technology
1 answer:
Andreyy894 years ago
8 0

Answer:

import sys

import turtle

import random

def n_pointed_star(total_points):

if total_points <= 4:

 raise ValueError('Not enough total_points')

area = 150

for coprime in range(total_points//2, 1, -1):

 if greatest_common_divisor(total_points, coprime) == 1:

  start = turtle.position()

  for _ in range(total_points):

   turtle.forward(area)

   turtle.left(360.0 / total_points * coprime)

  turtle.setposition(start)

  return

def greatest_common_divisor(a, b):

while b != 0:

 a, b = b, a % b

return a

   

turtle.reset()

n_pointed_star(5)

Explanation:

  • Inside the n_pointed_star function, check whether the total no. of points are less than or equal to 4 and then throw an exception.
  • Loop through the total_points variable and check whether the result  from greatest_common_divisor is equal to 1 or not and then set the starting position of turtle and move it.
  • Create the greatest_common_divisor which takes two parameters a and b to find the GCD.
  • Finally reset the turtle and call the n_pointed_star function.
You might be interested in
One purpose of fairy tales is to help children master the problems associated with growing up. Please select the best answer fro
-Dominant- [34]

Answer:

The answer is TRUE

Explanation:

7 0
3 years ago
Read 2 more answers
Create a program that a professor can use to display a grade for any number of students. Each student's grade is based on four t
chubhunter [2.5K]

Using the knowledge in computational language in C++ it is possible to write a code that organizes a student's grades in some subjects

<h3>Writing the program in C++</h3>

<em>#include<iostream.h></em>

<em>#include<conio.h></em>

<em>void main()</em>

<em>{</em>

<em>int i,n,sub1,sub2,sub3,sub4,totaltestscore; </em>

<em>cout<<"Enter the number of students : ";</em>

<em>cin>>n; </em>

<em>for(i=1;i<=n;i++) </em>

<em>{</em>

<em>cout<<" Enter the test score of subject 1 out of 100: ";</em>

<em>cin>>sub1; </em>

<em>cout<<" Enter the test score of subject 2 out of 100: ";</em>

<em>cin>>sub2; </em>

<em>cout<<" Enter the test score of subject 3 out of 100: ";</em>

<em>cin>>sub3; </em>

<em>cout<<" Enter the test score of subject 4 out of 100: ";</em>

<em>cin>>sub4; </em>

<em>totaltestscore=sub1+sub2+sub3+sub4;</em>

<em>if(totaltestscore>=372&&totaltestscore<=400) </em>

<em>cout<<" The grade of the student is : A "; </em>

<em>else</em>

<em>if(totaltestscore>=340&&totaltestscore<=371) </em>

<em>cout<<" The grade of the student is : B "; </em>

<em>else</em>

<em>if(totaltestscore>=280&&totaltestscore<=339) </em>

<em>cout<<" The grade of the student is : C "; </em>

<em>else</em>

<em>cout<<" The student fail "; </em>

<em>}</em>

<em>}</em>

See more about C++ at brainly.com/question/19705654

#SPJ1

3 0
3 years ago
Write a program that will prompt the user to enter an integer. The program should square the number and then print the squared n
Kay [80]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to compute sum and product

void square(int input)

{

   // variable to store the square of number

   long long squ_num;

   calculate the square of number

   squ_num=pow(input,2);

   // print the output

   cout<<"square of "<< input<<" is: "<<squ_num<<endl;

   

}

// driver function

int main()

{

   int n;

   // read the number until user enter 0

   do{

       cout<<"enter a number!! (0 to stop):";

     // read the input from user

       cin>>n;

       // call the function to calculate square of input number

       square(n);

       

   }while(n!=0);

 

return 0;

}

Explanation:

Declare a variable "n" to read the input number from user.Call the function  square() with parameter "n".In this function, it will calculate the square  of the input number and print it.This will repeat until user enter 0 as  input.Program will ends when user give 0 as input.

Output:

enter a number!! (0 to stop):5                                                                                                                                

square of 5 is: 25                                                                                                                                            

enter a number!! (0 to stop):7                                                                                                                                

square of 7 is: 49                                                                                                                                            

enter a number!! (0 to stop):11                                                                                                                              

square of 11 is: 121                                                                                                                                          

enter a number!! (0 to stop):0

3 0
4 years ago
To obtain your class E learner license, youll need too _
k0ka [10]
<h3>                                           Answer:</h3>

  To obtain you  class E Learner License,  you'll need to <u>Pass a literacy Test</u>

<h2>         </h2><h2>                 Can you Brainliest me?</h2>
8 0
3 years ago
Include the source code with comments for all modules in lab. you do not have to include test bench code. code without comments
hoa [83]
I like the UCF Football coach

7 0
3 years ago
Other questions:
  • Which activity constitutes legal computer activity?
    12·1 answer
  • Operating systems are designed to work with specific hardware. Which operating system works with Apple computers?
    8·2 answers
  • What type of topography should Carlos choose?
    5·1 answer
  • To move one screen to the left press ____.
    9·1 answer
  • In C, developers may access arrays via bracketed syntax like Java or by using * dereferencing notation. The following assignment
    5·1 answer
  • What is constructive criticism?
    5·1 answer
  • What effect does the interconnectedness of modern media have on society?
    14·2 answers
  • The meaning of belt drives
    10·1 answer
  • Redundancy can be implemented at a number of points throughout the security architecture, such as in ________. Group of answer c
    12·1 answer
  • Write a program to find all integer solutions to the equation 4x + 3y -9z = 5 for values of x, y, and z between 0 to 100.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!