CEIS 100 Week 4 Lab Assignment Help | Devry University

CEIS 100 Week 4 Lab Assignment Help | Devry University 


Week 4 Lab

Python Programming

A complete set of instructions can be found under this week's Lab section. The link to the lab report is here (Links to an external site.)Links to an external site..

Submit your lab for grading.

 

 

  
                                                                                    Lab Report 

DeVry University
College of Engineering and Information Sciences


Course Number: CEIS-100


Exercise Title: Python Programming.

 

 

OBJECTIVES

Create a Python program.

 

ASSUMPTIONS

In this lab, you will create a Python program that will prompt the user to answer a few questions. Check out this demonstration video for understanding of the process.Crtl+Click

 

http://www.screencast.com/t/ytpIfarUzp

 

 

 

 

I.                   Creating a Python Program

1.      Open IDLE using your Raspberry Pi or Citrix (http://lab.devry.edu), or download Python on your home computer: http://www.python.org/download/.

 

2.      Review the Week 4 Lesson for details on how to program in Python. An interactive tutorial is available in the Week 4 Lesson, and a video showing how to solve Part A, step by step, is available in the Lab.

 

3.      Ask the user to input user’s name. Then, ask the user to enter user’s age. If they are older than 16, then they can drive a car. Display this message along with their name.

 

4.      The code to accomplish this is below:

 

print("Welcome to the get to know you program")

name = input("What is your name? ")

age = int(input("What is your age? "))

if age>=16:

print("You can drive a car!")

 

print(name)

print("Nice to meet you!")

 

5.      Print out the results of the input values and a final message saying "Nice to meet you."

 

 

 

6.      The program should look like the following.

 

 image


7.      Insert your program into the lab report either by copying or pasting or typing it. You may also use a screenshot to show that the program works.You can include a digital picture using your phone or a Windows Screenshot. To include a screenshot in Windows, keep the IDLE window open and press the Print Screen button on your keyboard. Open the Word document lab report. Then, click Paste on the Home tab. This will paste the screenshot in Word. You can also use the Windows 7 Snipping tool to paste a screenshot.


II.                On your own with Python

Part A

 

1.      Open IDLE using your Raspberry Pi or Citrix (http://lab.devry.edu), or download Python on your home computer: http://www.python.org/download/ .

 

2.      Review Week 4 Lesson for details on how to program in Python. An interactive tutorial is available in the Week 4 Lesson, and a video showing how to solve Part A, step by step, is available in the Lab.

 

3.      Ask the user to input the user’s name. Next, ask the users to input thecity in which they live. Next, ask the user to input the temperature outside. If the temperature is greater than 60, display a message: “It is nice where you live.”Please note, when asking the user for a number, you need to convert the number to a different data type like integer or float (float means decimal values and integer means whole numbers). For temperature, you will need a float since it is possible to have a decimal value. Your input for temperature should look something like this:

 

temperature = float(input("What is the temperature? "))

 

4.      Write the code in Python to accomplish this task.


5.      Print out the results.

 

 6.      The program should look like the following.


image


7.      Enter your code into the lab report either by copying or pasting or typing it. You may also use a screenshot to show that the program works. You can include a digital picture using your phone or a Windows screenshot. To include a screenshot in Windows, keep the IDLE window open and press the Print Screen button on your keyboard. Open the Word document lab report. Then, click Paste on the Home tab. This will paste the screenshot in Word. You can also use the Windows 7 Snipping tool to paste a screenshot.


III. On your own with Python

1.      Go to code.org and click on learn. There are multiple tutorials in different programming languages here. Pick one of them and work through it. Write a few paragraphs of your experience below:


Part B

 

1.      In Part A, we used an if statement. Now, in Part B, we will add  more complexity to our program to make it repeat. Loops such as while loops and for loops can repeat a block of code. For example, we may want to print out all of the even numbers from 0 to a number that the user inputs. The following program will ask the user to enter a number set to maxNumber. A counter will start at 0. Then, the while loop will continue from the counter to maxNumber.

 

2.      Run the following program by entering 100 as the maxNumber. Then, try a few other numbers. What happens if you enter a negative number?

print("Welcome to the even number program")

maxNumber=int(input("Number to count up to?"))

count=0

while count<maxNumber:

print(count)

count=count+2

 

3.      Now that you have learned both if statements and loops, create a program combining both loops and if statements. For example, in the following program modified from the above example, once the count reaches 4, the program prints out "That's my favorite number."

 

print("Welcome to the even number program")

maxNumber=int(input("Number to count up to?"))

count=0

while count<maxNumber:

if count==4:

print("That's my favorite number!")

print(count)

count=count+2

 

 

4.      Now it's your turn.Combine both if statements and a loop. You can:

a.       Print out odd numbers and display a message if you hit a particular number.

b.      Display all numbers from 1100 and print a message if the number is greater than 50.

c.       Print multiples of 5 and display a message if the count is equal to 10.

d.      Any other combination of if statements and a loop.

 

 

 





Answer Detail

Get This Answer

Invite Tutor