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

Write a python program that takes 10 inputs from the user, and then prints how many inputs are odd and how many inputs are even. Use for loop.

Sample input:

2

6

8

3

9

2

6

4

3

7

Sample Output:

Even numbers = 6, Odd numbers = 4
Notice: I want this answer in different way without using append, format, len etc.
Write a function in a PYTHON to read the content of a text file “DELHI.TXT” and display all
those lines on screen, which are either starting with ‘D’ or starting with ‘M’.
3 digit Armstrong number
Assume a text file “Test.txt” is already created. Using this file, write a function to create three
files “LOWER.TXT” which contains all the lowercase vowels and “UPPER.TXT” which contains all
the uppercase vowels and “DIGIT.TXT” which contains all digits.

Write a program that reads a single line of input and prints the first and last characters of the given input and prints the asterisk character (*) in place of the remaining characters.Input


What is the value of pairs after the following assignment?
pairs = [ (x,y) for x in range(5,1,-1) for y in range(4,1,-1) if (x+y)%3 == 0 ]

Sum of the series

Write a program to find the sum S of the series where S = x - x^3 + x^5 + ....... upto N terms.

Input

The first line of input is an integer X. The second line of input is an integer N.

Explanation

If we take X value as 2 in the series upto 5 terms.

Then the series is 2 - 23 + 25 - 27 + 29

So, the output should be

410.

Sample Input 1

2

5

Sample Output 1

410

Sample Input 2

3

2

Sample Output 2

-24




Right Angled Triangle - 3

Given an integer number N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.

Input

The first line of input is a positive integer.

Explanation

For example, if the given number is

5, the output should be

______

| /

| /

| /

| /

|/


Sample Input 1

5

Sample Output 1

______

| /

| /

| /

| /

|/

Sample Input 2

7

Sample Output 2

________

| /

| /

| /

| /

| /

| /

|/




Hollow Right Triangle - 2

Given an integer number N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.

Note: There is a space after each asterisk (*) character.

Input

The first line of input is an integer N.

Explanation

In the given example the hollow right angled triangle of side

5. Therefore, the output should be

*

* *

* *

* *

* * * * *


Sample Input 1

4

Sample Output 1

*

* *

* *

* * * *

Sample Input 2

5

Sample Output 2

*

* *

* *

* *

* * * * *




Hollow Right Triangle

Given an integer number N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.

Note: There is a space after each asterisk (*) character.

Input

The first line of input is an integer N.

Explanation

In the given example the hollow right angled triangle of side

4. Therefore, the output should be

* * * *

* *

* *

*


Sample Input 1

4

Sample Output 1

* * * *

* *

* *

*

Sample Input 2

6

Sample Output 2

* * * * * *

* *

* *

* *

* *

*




LATEST TUTORIALS
APPROVED BY CLIENTS