Question

In: Computer Science

Solve please in python b) Create a program that shows a series of numbers that start...

Solve please in python

b) Create a program that shows a series of numbers that start at a and increase from 5 to 5 until reaching b, where a and b are two numbers captured by the user and assumes that a is always less than b. Note that a and b are not necessarily multiples of 5, and that you must display all numbers that are less than or equal to b.

c) Create a program that displays n characters on the screen that alternate between # and%, where n is an integer entered by the user.
Characters must be displayed one on each line.
Note that the first character to display is always #

For example:
If n = 5, you should show:
#
%
#
%
#

Solutions

Expert Solution

In this Python program,

Code a: Here, we are prompting the user to enter the values of a and b then we are iterating through the for loop starting from a with an increment of 5 till it reaches b with a loop variable i. Then we are printing the value i.
Code b: Here, we are prompting the user to enter the value of n then we are using a for loop starting from 1 to n(inclusive) then for odd indexes we are printing # and fir even indexes we are printing %.
(NOTE: Check the screenshot for Indentation, Usually this compiler will remove all the indentation that I mentioned)

(I believe that I made the code simple and understandable. If you still have any query, Feel free to drop me a comment)

Code b:

#Prompting and then reading the values of both a and b
a=int(input("Enter the value of a: "))
b=int(input("Enter the value of b: "))


print("The Range from",a,"to",b,"is")
#Iterating from a with an increment of 5 till it reaches b
for i in range(a,b+1,5):
print(i)

Code c:

#Prompting the user to enter the value of n
n=int(input("Enter the value of n: "))

#Iterating through all the values till we reach n
for i in range(1,n+1):
#Check if it is an odd index(1,3,5,...) print #
if(i%2!=0):
print("#")
#Check if it is an even index(2,4,6,...) print %
else:
print("%")

Please check the compiled program and its output for your reference:
Code-a:


Output:

Code b:

Output:

Hope this Helps!!!
Please upvote as well, If you got the answer?
If not please comment, I will Help you with that...


Related Solutions

Create a python program that prints the series from 5 to 500.
Create a python program that prints the series from 5 to 500.
Write a program in Python that will print first 100 numbers of the following series: 0,...
Write a program in Python that will print first 100 numbers of the following series: 0, 1, 1, 2, 3, 5, 8……..
Please fix all the errors in this Python program. import math def solve(a, b, c): """...
Please fix all the errors in this Python program. import math def solve(a, b, c): """ Calculate solution to quadratic equation and return @param coefficients a,b,class @return either 2 roots, 1 root, or None """ #@TODO - Fix this code to handle special cases d = b ** 2 - 4 * a * c disc = math.sqrt(d) root1 = (-b + disc) / (2 * a) root2 = (-b - disc) / (2 * a) return root1, root2 if...
Create this on Python Write a program that asks for three numbers. Check first to see...
Create this on Python Write a program that asks for three numbers. Check first to see that all numbers are different. If they’re not different, then exit the program. Otherwise, display the largest number of the three. Outputs: - Enter the first number: 4 - Enter the second number: 78 - Enter the third number: 8 (The largest number is 78.) Tasks - Complete the algorithm manually without using any built-in functions to find the largest number on list. -...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The...
USE PYTHON. Create a program that will ask a user to enter whole positive numbers. The program will use a while loop to let the program keep running. The user will be allowed to use the program as long as the quitVariable is equal to 'y' or 'Y'. When the user decides to quit playing, say "Thanks for playing!". The program will use a for loop to test if the number are even or odd. If even print "number is...
Please use Python 3 3). Write a function that writes a series of random numbers to...
Please use Python 3 3). Write a function that writes a series of random numbers to a text file named ‘random_number.txt’. Each random number should be in the range of 1 through 500. The function should let the user specify how many random numbers the file will hold. Then write another function that reads the random numbers from the ‘random_number.txt’ file, displays the numbers, and then displays the total of the numbers and the number of random numbers read from...
Please write in Python code please Write a program that creates a dictionary containing course numbers...
Please write in Python code please Write a program that creates a dictionary containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key-value pairs: Course...
In python 3 please: This program extends the earlier "Online shopping cart" program. (Start working from...
In python 3 please: This program extends the earlier "Online shopping cart" program. (Start working from your Program 7). (1) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps.(3 pt) ● Parameterized constructor which takes the customer name and date as parameters ● Attributes ○ customer_name (string) ○ current_date (string) ○ cart_items (list) ● Methods ○ add_item() ■ Adds an item to...
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
please solve the following in python: write a program for the decryption of 2-rail fence cipher....
please solve the following in python: write a program for the decryption of 2-rail fence cipher. For example, the input "Cmhmtmrooeoeoorw" should return "Comehometomorrow", and input "topaesw lyr" should return "two players".
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT