Write a python program that accepts a sentence

Assignment Help Python Programming
Reference no: EM132395303

Assignment: Part 1:

Question 1: Write a python program that finds all numbers divisible by 7 but not multiple of 5. The range of number for searching is between 2000 and 3200 (both included). Output should be printed in a comma-separated sequence on a single line.

Question 2: Write a python program that can compute the factorial of a given 2 numbers from the user. The results should be printed in a comma-separated sequence on a single line.

Input number 1: 3

Input number 2: 4

Sample Output: 6, 24

Question 3: Define a python class which has at least two methods:

getString: to get a string from console input.

printString: to print the string in upper case.

You should also include functions to invoke the above-mentioned methods.

Question 4: Write a program that accepts a comma separated sequence of words as input and print the words in a comma-separated sequence after sorting them alphabetically.

Sample input: without,hello,bag,world

Sample output: bag,hello,without,world

Question 5: Write a python program that accepts a sentence and calculate the number of letters and digits in the sentence.

Question 6: Define a function that receives two integer numbers in string form and compute their sum and print it in the console.

Question 7: Write a python program that reads from a text file and print all the unique words of the file in alphabetical order.

Question 8: Write a simple banking program using python that has four options: 1. View balance 2. Make a deposit 3. Make a withdrawal 4. Quit. You must implement classes and object for this program.

Question 9: Write a program that keep track of when our friend's birthdays are, and be able to find that information based on their name. Create a dictionary of names and birthdays. When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. The interaction should look something like this:

Welcome to the birthday dictionary. We know the birthdays of:

Albert Einstein

Benjamin Franklin

Ada Lovelace

Who's birthday do you want to look up?

User Input: Benjamin Franklin #Example

Benjamin Franklin's birthday is 01/17/1706 #This your program should print

Question 10: Given an array of data:

10
5
15
2
7
21

a. Write the code for the selection sort to sort the data and draw a table showing how the data is sorted using selection sort.

b. Write the code for Binary search algorithm to find the value 15 from the sorted array. Draw the tree diagram showing the binary search of the list.

Part 2:

Question 1: Explain what happens when the following recursive function is called with the value 4 as an argument

def example(n) :

if n > o:

print(n)

example(n-1)

Question 2: a. What are instance variables, and what role does the name "self" play in the context of a class definition?

b. How is the lifetime of an object determined? What happens to an object when it dies?

Question 3: Define a method for the Bank class that returns the total assets in the bank (the sum of all account balances).

Question 4: Two playing cards can be compared by rank. For example, an ace is less than a 2. When c1 and c2 are cards, c1.rank< c2.rank expresses this relationship. Explain how a method could be added to the Card class to simplify this expression to c1 < c2.

Question 5: Write a python program that calculates and prints the number of minutes in a year.

Question 6: Using python, write a loop that accumulates the sum of all of the numbers in a list named data. What is the purpose of the dir function and the help function?

Question 7: Write a function called isprime which takes a single integer argument and returns True if the integer is a prime number, and False otherwise. A prime number is a number with only two distinct divisors, 1 and itself.

Note: 1 is therefore not a prime number.

Question 8: Write a Python program that read a line of input from the user until the user enters a blank. The program should print out the total number of occurrences of each letter in the alphabet. These should be printed in alphabetical order. Your program should work like this:

> ./letters

hello world

d 1
e 1
h 1
l 3
o 2
r 1
w 1

Question 9: Why does Python code generate fewer types of syntax errors than code in other programming languages?

Question 10: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210

Question 11: Identify the error in the following program and write the correct python source code line = raw_input("Type a word") print "You typed", line line = line + "h" num = int(line) print "You typed the number ", num

Question 12: Describe two fundamental differences between terminal-based user interfaces and GUIs.
What roles do the parameters and the return statement play in a function definition?

Question 13: Write a python code to sort the given set of numbers in ascending order. You must not use any built-in functions of python.

Reference no: EM132395303

Questions Cloud

Determine which stakeholder groups have the most influence : Determine which stakeholder groups have the most influence on each of the elements identified in the formal SWOT analysis,
Supernormal growth period : a) Calculate the PV of the dividends paid during the supernormal growth period.
Calculate and also repayment amount including interest : Can you please use the FRA payoff formula to calculate and also repayment amount including interest
How company has used and implemented performance dashboards : Explain how your company has used and implemented performance dashboards (or not!) as part of its corporate strategy. What's worked well? What hasn't?
Write a python program that accepts a sentence : Write a python program that accepts a sentence and calculate the number of letters and digits in the sentence. Define a function that receives two integer.
Calculate the yield to maturity : Consider a 10% coupon bond, with semiannual coupons, face value of 1,000, 20 years to maturity, $987 price. Calculate the yield to maturity.
Calculate the yield to maturity : Consider a 10% coupon bond, with semiannual coupons, face value of 1,000, 20 years to maturity, $987 price. Calculate the yield to maturity.
What is the return on assets : Easter Egg and Poultry Company has $2,000,000 in assets and $1,400,000 of debt. It reports net income of $200,000. Show formula and work.
Rapidly changing from myriad of demographics : The contemporary workforce is rapidly changing from a myriad of demographics. The effective leader must be skilled in managing the diverse workforce

Reviews

Write a Review

Python Programming Questions & Answers

  Write a program using the requetinteger function

write a program using the 'requetInteger' function that will ask the user to type a value that will draw a line from one point on a picture to another.

  Develop a system for the Complex Word Identification

Class project: Complex Word Identification. The goal of the lab is to develop a system for the Complex Word Identification shared task

  Create table using a two-dimensional list that stores temp

Create table using a two-dimensional list that stores a Fahrenheit temperature and the equivalent Celsius temperature. Display the contents of the list.

  Calculate how many years it will take to double investment

Execute a quick calculator that prompts for the rate of return on an investment and calculates how many years it will take to double your investment.

  Implement core security features

What you will be implementing here is inspired by real world cases such as the Conficker work. To have any chance of defeating such a threat, you need to understand how they defend themselves.

  Write a program to sort the tuples by ascending order

You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string, age and height are numbers.

  Project title email spam filterabstractanalyze the emails

project title email spam filterabstractanalyze the emails and predict whether the mail is a spam or not a spam.to work

  Display the solution according to the aforementioned formula

Write a program that takes the three coefficients a, b, and c as input, computes and displays the solutions according to the aforementioned formula.

  Write a python program that will index a set of documents

You are going to write a python program that will index a set of documents and build a function to search through these documents using the index

  Write the statement needed to find out how many prime number

Assume a variable n has been associated with positive integer. Write the statements needed to find out how many prime numbers.

  Simulate the monty hall problem

In this problem, we will be writing pieces to simulate the Monty hall problem. Monty Hall was the host of "Let's Make a Deal" in the 1960's and 70's.

  Define what string operations are available

Define what string operations are available and how you use them

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd