Question

Assignment Content You recently graduated from college and are applying for a programming job that requires...

Assignment Content

  1. You recently graduated from college and are applying for a programming job that requires the understanding of loops in Python. The manager you are interviewing with has asked you to take an assessment to prove your programming knowledge. Below are the requirements for the programming skills test.

    In Python, create a program that meets the following requirements:

    • Take two integers from the user.
    • Save the lower number as x.
    • Save the largest integer as y.
    • Write a loop that counts from x to y by twos.
    • Print out the values of that loop using the Print function in Python.
    • Write another loop that adds x and y, and saves the value as Z.
    • Print out the values of Z using the Print function in Python.

    Provide the code and take a screenshot of the output. Then, paste the screenshot(s) into a Microsoft® Word document. PLEASE CODE IN PYTHON

Homework Answers

Answer #1

Code:

p, q = input("Enter two Integers: ").split() #taking two input together
# You can also take input one by one
#p = input("Enter First Integer")
#q = input("Enter Second Integer")

x=int(min(p,q)) #taking minimum value out of two variables p  and q
y=int(max(p,q)) #taking maximum value between p and q

#1st part
print("First loop")
for i in range(x,y,2):
    print(i,end=" ")

#2nd part
#For 2nd part you didn't mention condition for the loop and even by what value you
#want to increment so I am assuming the condition is same as above for loop
print("\n")
Z=0
print("Second loop")
for i in range(x,y,2):
    Z = x + y
    print(Z,end=" ")


#note: Syntax of range: range(start,stop,step) wherein the step
#I have initialized 2 because you want to count x to y by 2's
    



Output:

The value of Z never changes because we didn't change the value of variable x and y, so that's why every time loop iterate it prints 13 each time

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
Assignment Overview This programming exercise introduces generics and interfaces. The students must create methods that accept...
Assignment Overview This programming exercise introduces generics and interfaces. The students must create methods that accept generic parameters and perform operation on them. Deliverables A listing of the fully commented, working source code of the Java program Test data for the code A screen shot of the application in execution Step 1 Create a new project. Name it "Assignment_2_1". Step 2 Build a solution. Write the Java source code necessary to build a solution for the problem below:You have just...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include...
JavaScript Programming Assignment PLEASE NOTE:  You must create and call a main function, and if instructed include additional functions called by the main. Make sure to use ES6 style of keywords => instead of the older function and for local scope variables use the keyword let and not a keyword var. Make sure to follow the requirements and recheck before submitting. PROJECT GOAL: Write a program that is required to use nested loops to generate a triangle as shown in the...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
C# Lab 7A: Thank you, Grace Hopper. You may have heard the story, but the programming...
C# Lab 7A: Thank you, Grace Hopper. You may have heard the story, but the programming term “bug” is attributed to the computer legend Grace Hopper who, after diagnosing the problem with a program, determined it was because a bug (in this case, a moth) physically wedged itself under a vacuum tube – causing the machine to no longer work. We’ve come a long way since then... For this part of the lab, you are going to write a program,...
The last thing we will learn about in python is functions. Functions are a great way...
The last thing we will learn about in python is functions. Functions are a great way to organize your program - we use them to write code that is executed only under certain circumstances - for instance when you're using Amazon, any of the following are likely functions within their program: - Add item to cart, determine arrival date,  create a new address, compute taxes, compute shipping charges, charge credit card Because you can write a task-specific function once, and ensure...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
Using JAVA For this assignment, you will analyze code that uses a file input stream and...
Using JAVA For this assignment, you will analyze code that uses a file input stream and a file output stream. Read through the linked Java™ code. In a Microsoft® Word document, answer the following questions: Could this program be run as is? If not, what is it lacking? Does this program modify the contents of an input stream? In what way? What are the results of running this code? ********************************************** CODE TO ANALYZE  ******************************************************** /********************************************************************** *   Program:   Datasort *   Purpose:   ...
An advantage of programming is the ability to perform millions of calculations and dump it to...
An advantage of programming is the ability to perform millions of calculations and dump it to a file for plotting. This can be extremely useful for engineers if they are simulating or characterizing a system. Below you will calculate data, write it to a file, and plot the contents in excel. a) Create a csv file for writing. This can be done by creating a file with the open method as we have done in class but with a *.csv...
VBA LOOPS The two macros in this homework should be assigned to separate buttons and should...
VBA LOOPS The two macros in this homework should be assigned to separate buttons and should be located on the same worksheet. When you are done, upload your saved workbook below. Be sure to write your code in a module in the workbook you will submit, not in your personal workbooks or sheets. To access the correct module, go to your “Visual Basic,” right-click “Microsoft Excel Objects” in the workbook you are submitting, and then click “Insert” and “Module.” Problem...