Only the Even Ones
I have a list of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the list.
Can you do that for me?
Input:
33 54 32 11 8
Output:
2
54
32
8
Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah".
Let's try this out now!
Input
A line containing two integers separated by a space.
777·7Output
A line containing a string.
Jackpot!given an integer n as input, write a program to print a number diamond of 2*n -1 rows
input1: 5
input2:4
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1
1 2
1 2 3
1 2 3 4
1 2 3
1 2
1by CodeChum Admin
Numbers in threes are awesome! But the one last time was too lengthy to look at, so I just want to view it in a shorter but still readable format.
You okay with this task?
Instructions:
Output
A line containing integers divisible by 3 separated by a space.
3 6 9 12 15 18 21 24...ce
Back to Timeline
brightness_2
notifications
User
list
Details
Code
2. How a Coder Counts
by CodeChum Admin
Instructions:
Make a variable and assign it to an input() function that will accept an integer value. Make sure that the value is now holding a real integer and not just a default string, so make use of what you’ve learned on typecasting your input() functions on the past lessons.
Create a for loop that will print out numbers starting from 0 until the value of the inputted integer, each printed on separate lines. Make use of the range() function well in performing this task.
Instructions
Input
A line containing an integer.
10
Output
Multiple lines containing an integer.
1
2
3
4
5
6
7
8
9
10
Let us now try comparing two numbers by letting the user input two different numbers and say "Greater" if the first inputted number is greater than the second one, and "Lesser" if it’s the other way around.
Let's go!
Input
A line containing two different numbers separated by a space.
1.2·1.02Output
A line containing a string.
Greaterby CodeChum Admin
Are you good at spelling things? Well, with Python and its loops, it's as easy as 1-2-3! Let's try spelling some random words!
Instructions:
Instructions
Input
A line containing a string.
CodeChumOutput
Multiple lines containing a one-letter lowercase string.
c
o
d
e
c
h
u
m2. Squares
by CodeChum Admin
Instructions:
Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.
Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.
Instructions
Using a while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.
If the inputted integer is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept as your looping condition and don't forget to declare and initialize the variable you will be using for your loop condition and make sure the initial value will not make the condition false at first.
Input
Multiple lines containing an integer.
2
6
Output
Multiple lines containing an integer.
4
36
The greatest common divisor, also known as GCD, is the greatest number that will, without a remainder, fully divide a pair of integers.
Now, I want you to make a program that will accept two integers and with the use of loops, print out their GCD. Make good use of conditional statements as well.
Off you go!
Input
A line containing two integers separated by a space.
6·9Output
A line containing an integer.
3For those of you who may not now, a factorial is a product of multiplying from 1 until the number. Now, you must make a program that will accept an integer and then print out its factorial using loops.
Are you up for this task?
Instructions:
Input
A line containing an integer.
5Output
A line containing an integer.
120