very noob question - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

very noob question

ZeroOverRidZeroOverRid Posts: 23Member
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"

Comments

  • DarkAvengerDarkAvenger Posts: 1Member
    : 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.
Sign In or Register to comment.