Need help please

For students who are taking a programming course, may be restricted in what they can use, or have other unusual limitations on solving their task.

Need help please

Postby callia » Mon Sep 12, 2016 3:43 pm

Hello everyone! I will be a regular here for the fall semester :) I can't tell you enough in advance how much I will appreciate any help you are able to give. I hope that as I learn, I will also be able to offer up some help and give back.

That said, the assignments I am needing help on right now are very basic as we just started. The one I am stuck on right now says:
-----------------
Read in two numbers from user input without a prompt, add them, and print the result.
Hint: Use int() to convert the numbers to integers.

Note: These activities may test code with different test values. This activity will perform two tests: the first with num1 = 5 and num2 = 10, the second with num1 = 6 and num2 = 3
-----------------
How do I tell it to run them separately so that I get a 15 for the first test and a 9 for the second test? Does that make sense...
Here are my screenshots:
python1.JPG
python1.JPG (66.72 KiB) Viewed 1059 times

python2.JPG
python2.JPG (66.52 KiB) Viewed 1059 times


Thank you in advance for helping me out!!
Last edited by Yoriz on Mon Sep 12, 2016 3:48 pm, edited 1 time in total.
Reason: First post lock.
User avatar
callia
 
Posts: 4
Joined: Mon Sep 12, 2016 3:36 pm

Re: Need help please

Postby buran » Mon Sep 12, 2016 4:14 pm

Welcome to the forum. For start read Forum Rules - e.g. don't post images, but code in CODE tags.

As to your question - read your assignment carefully:
Read in two numbers from user input without a prompt, add them, and print the result.
i.e. don't hard-code the values
We are moving to http://www.python-forum.io as of 1 October. Did you register there?
buran
 
Posts: 372
Joined: Tue Apr 08, 2014 4:53 pm
Location: Bulgaria, EU

Re: Need help please

Postby nilamo » Mon Sep 12, 2016 4:16 pm

callia wrote:Read in two numbers from user input without a prompt, add them, and print the result.
Hint: Use int() to convert the numbers to integers.

The very first thing is to read numbers from user input. Start there :p

The assignment is telling you that it's going to feed you two numbers, and you need to add them together. You're not reading anything from the input, and instead always printing 15.
This forum is shutting down. Future discussion should take place at http://python-forum.io
User avatar
nilamo
 
Posts: 87
Joined: Thu Jul 21, 2016 8:00 pm
Location: Michigan

Re: Need help please

Postby Ofnuts » Mon Sep 12, 2016 4:18 pm

You have misunderstood the problem statement. You have to get input from the user, not use hardcoded values (which is why you have to use int() because user input is a string, not a number...)

Also
Code: Select all
someint=int('123')

Is better written:
Code: Select all
someint=123
This forum has been moved to http://python-forum.io/. See you there.
User avatar
Ofnuts
 
Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987

Re: Need help please

Postby callia » Mon Sep 12, 2016 5:42 pm

Code: Select all
num1 = int(input())
num2 = int(input())

print(num1 + num2)


THANK YOU!!!! :D

Edit: Sorry for the images, I'll post code from now on. I didn't know how to explain what I was trying to do. :oops:
User avatar
callia
 
Posts: 4
Joined: Mon Sep 12, 2016 3:36 pm


Return to Homework

Who is online

Users browsing this forum: No registered users and 1 guest