![rileymorrison5836](/avatars/43728.jpg)
rileymorrison5836
12.10.2020 •
Computers and Technology
Edhesive python 3.7 Code Practice
Instructions
When we read code and predict its output, it is called tracing code.
For this lesson, you will come up with your own challenging algorithm for other students to trace. It must contain at least 5 if statements and use at least one AND or OR boolean condition.
Note: Elif or else statements will not count - your statements must be if statements. Each if statement should use a unique variable name.
For this challenge, try reading 3 or 4 of your classmates' code as well. Trace their code and predict what it will output, then check the code by running it to see if you got it right, and submit your work for a grade.
Solved
Show answers
More tips
- S Science and Technology Exploring Our Galaxy: How Many Planets are in the Milky Way?...
- S Science and Technology Colliders: How They Work and Why They Matter...
- A Animals and plants Unraveling the Mystery of Loch Ness: What Does the Loch Ness Monster Look Like?...
- L Leisure and Entertainment How Many Seasons are There in the TV Show Interns?...
- S Sport Playing Bowling: Rules and Advice for Novices...
- L Leisure and Entertainment The Best Film of 2010: A Look Back at the Academy Awards...
- S Sport How to Learn Swimming? Simple Tips for Beginners...
- C Computers and Internet What is Web 2.0 and How Does it Work?...
- C Computers and Internet War of Social Media: Which Platform is the Leader?...
- C Computers and Internet How to Get Rid of Spam in ICQ?...
Answers on questions: Computers and Technology
- H History 1. The Herztsprung-Russell diagram shown below is used to group stars based on specific physical pro unique to each star, Hertzsprung Russell Diagram Forte Tromperature, Kevin...
- G Geography What are the advantages and disadvantages of the north america free trade agreement {nafta{ for mexico?...
- E English The book hatchet chapter 15 .describe brian s method of keeping track of time...
Ответ:
#include <stdio.h>
int main()
{
int i, j, n, prime;
printf("Enter till where we want to find prime number: ");
scanf("%d", &n);
for(i=2; i<=n; i++)
{
prime = 1;
for(j=2; j<=i/2; j++)
{
if(i%j==0)
{
prime = 0;
break;
}
}
if(prime==1)
{
printf("%d, ", i);
}
}
return 0;
Explanation:
A number which is divisible by 1 and itself is called prime number. Here in the program we start by taking number from 1 to n , where n is the last number till which we are required to find prime numbers. Then we start the loop by taking two for loops one for running the numbers from 1 to n and the inner for loop to check whether the number is divisible other than 1 and itself. We take the current number as prime =1. If the number is still not divisible by number other than 1 and itself we consider that number to be prime and print it.