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

4. Leftovers

by CodeChum Admin


We Filipinos are quite known for the habit of leaving at least one of the many pieces of food on the plate as it can't be equally divided among all at most times. Just like when 3 people decide to eat a pizza of 10 slices, there will often be at least one slice left on the box. To accurately show just how many pieces of things are left when divided by a certain number, we code it using modulo.


Care to do it for me?


Input


A line containing two integers separated by a space.


10 3

Output


A single line containing an integer.


1


3. The More, The Lengthier

by CodeChum Admin


I think it's already a given that two sentences combined will always be longer than a single sentence alone, but to prove just how long two sentences can be, why don't we let our program show the combined length of the two randomly inputted strings?


Let's get it on!


Input


Two lines containing a string on each.


Python is fun

I love CodeChum


Output


A single line containing an integer.


28


2. Quotation Duo

by CodeChum Admin


Quotation marks are usually paired with a similar type, like a double quote (") paired with another double quote ("), and the same goes for single quotes ('). However, I'd like to try complicating things by putting together a pair of a double quote(") and a single quote(') in one statement!


Can you do this simple challenge?


Output


A line containing a string.


"'


1. Triple Slash

by CodeChum Admin


Samurais are so awesome! I'd like to imitate their amazing sword skills some time but I just don't have the courage to harm myself, so I'd just like to print out three forward slashes (\) to digitally imitate the samurai's triple slash skill. Haha!




Sounds easy, right? Then code it now!


Output


Three lines with a single backslash symbol.


\

\

\


my output:

12x^4 + 9x^3 - 5x^2 - 1x - 1


excepted output:

12x^4 + 9x^3 - 5x^2 - x - 1


For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.



Write a program to assist a college student in selecting an appropriate humanities or social science course as part of their degree.The college maintains a list of approved transfer courses that are available for AAS degrees like Computer Technology.use the following as eligible courses:

​Social science​ Humanities

​​ECO 210​​​​​ART 101

​​GEO 101​​​​​ENG 102

​​SOC 101​​​​​MUS 105

​​PSY 201​​​​​PHI 101

​​HIS 101​​​​​REL 101

​​PSC 201​​​​​

Create 2 lists for social science and humanities courses.Ask a student the course number they would like to take to fulfill the social science requirement.Search your list to see if the course is an acceptable course in that category.If so tell them the course they selected is fine.If not tell them that the course is not eligible and then display for them all the eligible courses.Repeat the same structure for humanities courses.The program should work for any number of courses in the lists


Fibonacci numbers are a sequence of integers, starting with 1, where the value of each number is the sum of the two previous numbers, e.g. 1, 1, 2, 3, 5, 8, etc. Write a function called fibonacci that takes a parameter, n, which contains an integer value, and have it return the nth Fibonacci number. (There are two ways to do this: one with recursion, and one without.)


1. The program should initialize with two variables, one called balance that starts with a float of 0, and one called otherBalance that also starts with a float of 0. [5% marks] 2. Create the following functions: i) getBalance() [5% marks] ■ This should only return the value of balance ii) getOtherBalance() [5% marks] ■ This should only return the value of otherBalance iii) printBalances() [10% marks] ■ This should call getBalance() and getOtherBalance(), and print the returned values out with a dollar symbol and two decimal places (i.e., $10.99) (Hint: you can use format() function here to print the returned values) iv) deposit(money) [15% marks]


Develop a program to read the name, birthday and gender of a person from a file and output the name and ten-digit identity card (NIC) number to another file , each name starting on new line (see

The only input to the program is the name of the file. The output of the programme is the file "output.txt".
rules for NIC number.
The first four digits of the ID card is the birth year.
The next three digits are the number of days to the birth date from January 1st of that year. If the person is a female, 500 is added to that value.
The next three digits are assigned in the order of submission for a particular birth year.
The input file contains the records in the order of submission where each attribute is space separated.
In example , Aruni is the second entry in the year 1990. Therefore the last three digits of the NIC are 002.
Assume there are only 999 entries per year.
Example:
Saman 1990-05-03 M
Aruni 1990-04-06 F

Saman 1990123001




You may use the function,

days_to_birthday(date)

Alphabetic Symbol

Write a program to print the right alphabetic triangle up to the given N rows.Input


The input will be a single line containing a positive integer (N).Output


The output should be N rows with letters.

Note: There is a space after each letter.Explanation


For example, if the given number of rows is 4,

your code should print the following pattern.

A 
A B 
A B C 
A B C D




Sample Input 1

4

Sample Output 1

A

A B

A B C

A B C D

Sample Input 2

6

Sample Output 2

A

A B

A B C

A B C D

A B C D E

A B C D E F




LATEST TUTORIALS
APPROVED BY CLIENTS