by CodeChum Admin
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
A line containing integers separated by a space.
33·54·32·11·8
Output
Multiple lines containing an integer.
2
54
32
8
by CodeChum Admin
I want you to make a array/list of numbers for me. All you have to do is make a program that will let me input any random integer in one line. Afterwards, it will then print out all the numbers I've inputted, on separate lines.
Care to do that for me?
Input
A line containing integers separated by a space.
1·64·32·2·11
Output
Multiple lines containing an integer.
1
64
32
2
11
Unit 7 Submission
# name : [animal type, age, sex]
animal_shellter = {
"rocky": ["dog",2,"male"],
"judy": ["dog",2,"female"],
"Malisa": ["dog",8,"female"],
"Punk": ["hamster",7,"male"],
"Kendy": ["cat",12,"male"],
"Monalisa": ["cat",5,"female"],
}
print(animal_shellter)
print("")
def invert(d):
inverse = dict()
for key in d:
val = d[key]
for item in val:
if item not in inverse:
inverse[item] = [key]
else:
inverse[item].append(key)
return inverse
inverted_shellter = invert(animal_shellter)
print(inverted_shellter)
given an integer N as input write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) .
write a program to find armstrong numbers in the given range A to B (including A and B). an N -digit number is armstrong number if the number is equal to the sum of the Nth power of its digits.
Two variables, num and cost have been declared and given values: num is an integer and cost is a double. Write a single statement that outputs num and cost to standard output. Print both values (num first, then cost), separated by a space on a single line that is terminated with a newline character. Do not output any thing else
by CodeChum Admin
We've already made arraying/listing the easy way, but how about arraying/listing and printing the list in reverse order?
Make a program that will input an integer and then using loops, add items on an array/list one by one for the same number of times as that of the first inputted integer. Then, print out the array/list in reverse order, that is, starting from the last item on the array/list down to the first one, each in separated lines.
Input
The first line contains the size of the array/list. The next lines contains the items of the array/list (integers).
5
1
64
32
2
11
Output
Multiple lines containing integers.
11
2
32
64
1
by CodeChum Admin
You already know how to access the middle value of a certain string using index positions, right? Then let's put your learnings to practice.
Make a program that shall input a long string that contains an odd number of individual strings separated by comma. Afterwards, input the string that's located in the middle index position.
Let's do this.
Input
A line containing a string separated by a comma.
Python,is,fun
Output
A line containing a string.
is
by CodeChum Admin
Make a program that will accept an integer and loop for the same number of times as that of the inputted integer and input random integers and add it to the array/list one by one, per line. Afterwards, make your program accept another random integer.
Using that final integer, compare from your array/list if the final integer's value is also present in your current array/list. If so, print "Present"; otherwise, print "None".
Start coding now!
Input
The first line contains the size of the array/list. The next lines contain the integers. The last line contains an integer to be searched.
5
3
21
2
5
23
2
Output
A line containing a string.
Present
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