- 3

How can I solve 30 code project in python.

4th Feb 2022, 6:20 PM
Abdul Wasay Ali Khaled
Abdul Wasay Ali Khaled - avatar
9 Réponses
0
You have to change you code to skip all the even numbers(2,4,,8, 3579182). All even numbers are divisible by 2. So, you have to skip all the numbers that is divisible by 2. Hint: use "if" with "continue" statement.
5th Feb 2022, 5:21 AM
Scarlet Witch
Scarlet Witch - avatar
+ 3
one by one
4th Feb 2022, 6:23 PM
Davinder Kumar
Davinder Kumar - avatar
+ 2
Wasay Ali Are you asking about the FizzBuzz code project, some other specific project, or how to answer 30 code projects in Python? If FizzBuzz, then please share your code so we may help you further.
4th Feb 2022, 8:40 PM
ChaoticDawg
ChaoticDawg - avatar
0
FizzBuzz is a well known programming assignment, asked during interviews. The given code solves the FizzBuzz problem and uses the words "Solo" and "Learn" instead of "Fizz" and "Buzz". It takes an input n and outputs the numbers from 1 to n. For each multiple of 3, print "Solo" instead of the number. For each multiple of 5, prints "Learn" instead of the number. For numbers which are multiples of both 3 and 5, output "SoloLearn". You need to change the code to skip the even numbers, so that the logic only applies to odd numbers in the range. n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x)
5th Feb 2022, 4:55 AM
Abdul Wasay Ali Khaled
Abdul Wasay Ali Khaled - avatar
0
n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") elif x%2==0: continue Check this...Scarlet Witch
5th Feb 2022, 5:39 AM
Abdul Wasay Ali Khaled
Abdul Wasay Ali Khaled - avatar
0
I solved it like this and it seemed too easy! I'm no coder, so is it really this easy?! n = int(input()) for x in range(1, n, 2): #added a 2 here if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x)
20th Jun 2022, 5:20 AM
0
3rd Oct 2022, 12:02 PM
Soliman M Ghandour
Soliman M Ghandour - avatar