Python

Moderators: None (Apply to moderate this forum)
Number of threads: 474
Number of posts: 1166

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
very noob question Posted by ZeroOverRid on 13 Sept 2007 at 2:54 PM
hello I just started programming in python today and I am going to make a binary program for the heck of it. but so far I ran into a problem. for some reason it will not print 1. any help would be great thanks "
ps what is the difference from int(raw_input("ajajaj")) to input("aaaa")
I am not done with the program yet

name = raw_input("Please enter your name: ")
print "Hello", name, "Welcome to my Binary Program "
binary = int(raw_input("Please enter a number between 1-255: "))
if binary >= 255:
binary = binary - 128
print "1"

I figure it out but I have another question. here is the code I did to print 1 but I don't understand how it work? any help would be great

name = raw_input("Please enter your name: ")
print "Hello", name, "Welcome to my Binary Program "
binary = int(raw_input("Please enter a number between 1-255: "))
if binary >= 255: binary = binary - 128
print "1"
Report
Re: very noob question Posted by DarkAvenger on 15 Mar 2008 at 5:21 AM
: hello I just started programming in python today and I am going to
: make a binary program for the heck of it. but so far I ran into a
: problem. for some reason it will not print 1. any help would be
: great thanks "
: ps what is the difference from int(raw_input("ajajaj")) to
: input("aaaa")
: I am not done with the program yet
:
: name = raw_input("Please enter your name: ")
: print "Hello", name, "Welcome to my Binary Program "
: binary = int(raw_input("Please enter a number between 1-255: "))
: if binary >= 255:
: binary = binary - 128
: print "1"
:
: I figure it out but I have another question. here is the code I did
: to print 1 but I don't understand how it work? any help would be
: great
:
: name = raw_input("Please enter your name: ")
: print "Hello", name, "Welcome to my Binary Program "
: binary = int(raw_input("Please enter a number between 1-255: "))
: if binary >= 255: binary = binary - 128
: print "1"

In first case you have a problem with indentation block. In second case you have if loop in one row, so there's no indentation needed. Seems that's all.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.