Python Forum
how to make a program with a certain number of multiples?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to make a program with a certain number of multiples?
#1
how to make a program if it met with certain multiples of these numbers will produce a different output
example: I have numbers 1 - 20 these numbers will have the same output except 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 plus the string in front to distinguish that they are multiples of 2 besides their multiples of 2 only has regular integer output.
output:
1
2 different
3
4 different
5
6 different
7
8 different
9
10 different
etc

how do you make the program?

I've tried using a for loop and range function with an if statement but it still produces output that doesn't match what I want
Reply
#2
Hello, post the code which you used (in [python] code tags). It's quite likely that your code is close to solution you want, just need a little tweaking.
You can also post the output of your current code (in [output] tags).
Reply
#3
Try below to see if that helps,

x=int(input("enter max numbers to test: "))
y=int(input("multiple of whihc number to be different: "))
i=1
while (i <= x ):
	if ( i % y == 0 ):
		print("--->", i)
	else:
		print(i)
	i += 1
	
Best Regards,
Sandeep

GANGA SANDEEP KUMAR
Reply
#4
(Jan-01-2020, 01:50 PM)sandeep_ganga Wrote: Try below to see if that helps,

x=int(input("enter max numbers to test: "))
y=int(input("multiple of whihc number to be different: "))
i=1
while (i <= x ):
	if ( i % y == 0 ):
		print("--->", i)
	else:
		print(i)
	i += 1
	
Best Regards,
Sandeep

GANGA SANDEEP KUMAR

Thank you for your help :)

(Jan-01-2020, 01:37 PM)j.crater Wrote: Hello, post the code which you used (in [python] code tags). It's quite likely that your code is close to solution you want, just need a little tweaking.
You can also post the output of your current code (in [output] tags).

Alright, thanks for the advice Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  prefix ID Number with 0,00 make 3 digit. mg24 1 708 Oct-06-2022, 07:20 AM
Last Post: ibreeden
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,129 Feb-25-2022, 06:31 PM
Last Post: jao
Smile Help making number analysis program Dainer 2 1,732 Jun-24-2021, 09:55 PM
Last Post: jefsummers
  How to make a Vocal synthesizer program on Python? Seadust 3 3,490 Jan-28-2021, 06:26 PM
Last Post: gonnach
  I want to create small multiples grouped bar plot, and facing some aesthetics issuess dev_kaur 0 1,588 Dec-05-2020, 08:49 AM
Last Post: dev_kaur
  How to make a Python program run in a dos shell (cmd) Pedroski55 2 2,258 Nov-09-2020, 10:17 AM
Last Post: DeaD_EyE
  multiprocess hang when certain number is used in the program esphi 7 3,114 Nov-06-2020, 03:49 PM
Last Post: esphi
  I try to make Heron formula program abcd 7 3,329 Oct-22-2020, 12:48 AM
Last Post: abcd
  Make a Python program executable in Windows Pedroski55 1 2,067 Sep-26-2020, 12:34 AM
Last Post: bowlofred
  Make an array of string number in a List polantas 5 3,032 May-27-2020, 07:18 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020