Python Answers

Questions answered by Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Remember the game of FizzBuzz from the last time? Well, I thought of some changes in the game, and also with the help of loops as well. Firstly, you'll be asking for a random integer and then loop from 1 until that integer. Then, implement these conditions in the game:


print "Fizz" if the number is divisible by 3

print "Buzz" if the number is divisible by 5

print "FizzBuzz" if the number is divisible by both 3 and 5

print the number itself if none of the above conditions are met

Input


A line containing an integer.


15

Output


Multiple lines containing a string or an integer.


1

2

Fizz

4

Buzz

Fizz

7

8

Fizz

Buzz

11

Fizz

13

14

FizzBuzz


No one likes homework, but your math teacher has given you an assignment to find the sum of the first N numbers.


Let’s save some time by creating a program to do the calculation for you!


Take a number N as input and output the sum of all numbers from 1 to N (including N).


Sample Input

100


Sample Output

5050


Explanation: The sum of all numbers from 1 to 100 is equal to 5050.


You are given three numbers. Check if any of the numbers exist in the range from 10 to 20 (including 10 and 20).

input is

2

4

6

output should be

false


1. Anagrams!

by CodeChum Admin

Two strings are called anagrams, if they contain the same characters, but the order of the characters may be different.


Given a string consisting of lowercase letters and question marks, s1, and another string consisting of lowercase letters, s2, determine whether these two strings could become anagrams by replacing each ? character in s1 with a letter.


Input


1. First string


Constraints

Contains only lowercase letters and/or question marks

2. Second string


Constraints

Contains only lowercase letters

Output


The first line will contain a message prompt to input the first string.

The second line will contain a message prompt to input the second string.

The last line contains the message "anagram" if the strings could become anagrams by replacing all the ? characters of s1 with letters and "false" otherwise.


•Create a class named Shape with a function that prints "This is a shape". Create another class named Polygon inheriting the Shape class with the same function that prints "Polygon is a shape". Create two other classes named Rectangle and Triangle having the same function and inherited from polygon class, which prints "Rectangle is a polygon" and "Triangle is a polygon" respectively. Again, make another class named Square inherited from rectangle having the same function which prints "Square is a rectangle".

Now, try calling the function by the object of each of these classes.


•Create two classes named Mammals and MarineAnimals. Create another class named BlueWhale which inherits both the above classes. Now, create a function in each of these classes which prints "I am mammal", "I am a marine animal" and "I belong to both the categories: Mammals as well as Marine Animals" respectively. Now, create an object for each of the above class and try calling

1 - function of Mammals by the object of Mammal

2 - function of MarineAnimal by the object of MarineAnimal

3 - function of BlueWhale by the object of BlueWhale

4 - function of each of its parent by the object of BlueWhale


Create a binary file with roll no name and marks. Input a roll no and update the mark


Groupings

by CodeChum Admin


Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.


Instructions:

Create a variable that accepts a positive odd integer.

Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.

Reverse the order of the list. Then, print out the list's new order in this manner:

[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.


Input

The first line contains an odd positive integer.

The next lines contains an integer.


7

1

2

3

4

5

6

7


Output

A line containing a list.


[7,6,5]-[4]-[3,2,1]



Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.




Instructions:



Create a variable that accepts a positive odd integer.



Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.



Reverse the order of the list. Then, print out the list's new order in this manner:



[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.





Input



The first line contains an odd positive integer.



The next lines contains an integer.



7


1


2


3


4


5


6


7





Output



A line containing a list.



[7,6,5]-[4]-[3,2,1]




IPL Match Details



Write a program that reads all the match outcomes and summarizes the information of all the matches.


Points are given to the terms based on the outcome of the match.


A win earns a team 3 points.A draw earns 1.A loss earns 0.


The following information is expected:


MP:Matches Played


W:Matches Won


D:Matches Drawn(Tied)


L:Matches Lost


P:Points



The team information should be displayed in descending order of points.



Sample input 1


6


CSK;RR;loss


RR;DD;draw


MI;KKR;win


KKR;RR;loss


CSK;DD;draw


MI;DD; draw



Sample output 1


Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7


Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4


Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3


Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1


Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0

LATEST TUTORIALS
APPROVED BY CLIENTS