Python not running my program without any error












0















I need to create a program that will convert Base 10 numbers in Base 2.



Next is the code, it can not run as expected even if it has no error:



E = input('Please enter a number') 
Eint= int(E)
for N in range(100,0):
while 2**N > Eint:
N = N-1
print(0)
if B**N <= Eint:
Eint = Eint - 2**N
print(1)
Print('finished')


When I'm running it it will ask me the number but that's all, thank you for your help guys.



enter image description here










share|improve this question




















  • 4





    range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

    – EdChum
    Nov 14 '18 at 13:26













  • sorry i didn't saw your answer. i would like it to go from a N number to 0,

    – Diamonddeo
    Nov 14 '18 at 13:50











  • Then you want range(100,-1,-1)

    – EdChum
    Nov 14 '18 at 13:58











  • Okay thanks,i will try

    – Diamonddeo
    Nov 14 '18 at 14:06











  • now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

    – Diamonddeo
    Nov 14 '18 at 14:06
















0















I need to create a program that will convert Base 10 numbers in Base 2.



Next is the code, it can not run as expected even if it has no error:



E = input('Please enter a number') 
Eint= int(E)
for N in range(100,0):
while 2**N > Eint:
N = N-1
print(0)
if B**N <= Eint:
Eint = Eint - 2**N
print(1)
Print('finished')


When I'm running it it will ask me the number but that's all, thank you for your help guys.



enter image description here










share|improve this question




















  • 4





    range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

    – EdChum
    Nov 14 '18 at 13:26













  • sorry i didn't saw your answer. i would like it to go from a N number to 0,

    – Diamonddeo
    Nov 14 '18 at 13:50











  • Then you want range(100,-1,-1)

    – EdChum
    Nov 14 '18 at 13:58











  • Okay thanks,i will try

    – Diamonddeo
    Nov 14 '18 at 14:06











  • now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

    – Diamonddeo
    Nov 14 '18 at 14:06














0












0








0








I need to create a program that will convert Base 10 numbers in Base 2.



Next is the code, it can not run as expected even if it has no error:



E = input('Please enter a number') 
Eint= int(E)
for N in range(100,0):
while 2**N > Eint:
N = N-1
print(0)
if B**N <= Eint:
Eint = Eint - 2**N
print(1)
Print('finished')


When I'm running it it will ask me the number but that's all, thank you for your help guys.



enter image description here










share|improve this question
















I need to create a program that will convert Base 10 numbers in Base 2.



Next is the code, it can not run as expected even if it has no error:



E = input('Please enter a number') 
Eint= int(E)
for N in range(100,0):
while 2**N > Eint:
N = N-1
print(0)
if B**N <= Eint:
Eint = Eint - 2**N
print(1)
Print('finished')


When I'm running it it will ask me the number but that's all, thank you for your help guys.



enter image description here







python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 13:53









lagom

1




1










asked Nov 14 '18 at 13:24









DiamonddeoDiamonddeo

12




12








  • 4





    range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

    – EdChum
    Nov 14 '18 at 13:26













  • sorry i didn't saw your answer. i would like it to go from a N number to 0,

    – Diamonddeo
    Nov 14 '18 at 13:50











  • Then you want range(100,-1,-1)

    – EdChum
    Nov 14 '18 at 13:58











  • Okay thanks,i will try

    – Diamonddeo
    Nov 14 '18 at 14:06











  • now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

    – Diamonddeo
    Nov 14 '18 at 14:06














  • 4





    range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

    – EdChum
    Nov 14 '18 at 13:26













  • sorry i didn't saw your answer. i would like it to go from a N number to 0,

    – Diamonddeo
    Nov 14 '18 at 13:50











  • Then you want range(100,-1,-1)

    – EdChum
    Nov 14 '18 at 13:58











  • Okay thanks,i will try

    – Diamonddeo
    Nov 14 '18 at 14:06











  • now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

    – Diamonddeo
    Nov 14 '18 at 14:06








4




4





range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

– EdChum
Nov 14 '18 at 13:26







range(100,0) produces an empty range see the docs the 0 is the stop arg, what range are you intending to create

– EdChum
Nov 14 '18 at 13:26















sorry i didn't saw your answer. i would like it to go from a N number to 0,

– Diamonddeo
Nov 14 '18 at 13:50





sorry i didn't saw your answer. i would like it to go from a N number to 0,

– Diamonddeo
Nov 14 '18 at 13:50













Then you want range(100,-1,-1)

– EdChum
Nov 14 '18 at 13:58





Then you want range(100,-1,-1)

– EdChum
Nov 14 '18 at 13:58













Okay thanks,i will try

– Diamonddeo
Nov 14 '18 at 14:06





Okay thanks,i will try

– Diamonddeo
Nov 14 '18 at 14:06













now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

– Diamonddeo
Nov 14 '18 at 14:06





now it's printing a lot of 0 except for the last term and it's printing "finished at the end"

– Diamonddeo
Nov 14 '18 at 14:06












2 Answers
2






active

oldest

votes


















0














From a quick inspection, range(100,0), B, and Print() are three culprits here! If you want to pass through numbers from 0 to 99, then range(100) is what you need. Now, what is B? Print should be written in lower case: print.



After we fix these syntax errors, let us try to revisit the program and understand what it is supposed to do. Have fun :-)



EDIT to fix the code in the question:



E = input('Please enter a number: ') 
Eint = int(E)
for N in range(8,-1,-1):
if 2**N > Eint:
print(0, end='')
else:
Eint = Eint - 2**N
print(1, end='')

print()
print('finished')


Please note that Python is a language that uses indentations to denote code blocks. This code will convert a decimal to binary. Now, note that the range start of 8 gives you a hint about the upper bound of the number that the code can translate. Therefore, an if condition must be added after the second statement to ensure we are not attempting to convert a number that is too large. Enjoy!






share|improve this answer


























  • Okay. I decided to debug the program for you. Please see the edited response above :-)

    – faris
    Nov 14 '18 at 14:10











  • Thank you i will try it

    – Diamonddeo
    Nov 14 '18 at 14:18











  • It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

    – Diamonddeo
    Nov 14 '18 at 14:22













  • You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

    – faris
    Nov 14 '18 at 14:44











  • thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

    – Diamonddeo
    Nov 14 '18 at 15:01



















0














If it helps check my solution too. Because I guess you don't want to see the result on separate lines, so I create a list for you to see the result in one line.



E = int(input('Please enter a numbern'))
Eint = E
base_two=
while E > 0:
a = int(float(E%2))
base_two.append(a)
E = (E-a)/2
base_two.append(0)
string = ""
for j in base_two[::-1]:
string = string+str(j)
print("Binary for", Eint, "is", string)
print('finished')


I was late a little bit :)






share|improve this answer


























  • Thank you for your help ! it's working so good ah ah

    – Diamonddeo
    Nov 14 '18 at 14:31











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301293%2fpython-not-running-my-program-without-any-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














From a quick inspection, range(100,0), B, and Print() are three culprits here! If you want to pass through numbers from 0 to 99, then range(100) is what you need. Now, what is B? Print should be written in lower case: print.



After we fix these syntax errors, let us try to revisit the program and understand what it is supposed to do. Have fun :-)



EDIT to fix the code in the question:



E = input('Please enter a number: ') 
Eint = int(E)
for N in range(8,-1,-1):
if 2**N > Eint:
print(0, end='')
else:
Eint = Eint - 2**N
print(1, end='')

print()
print('finished')


Please note that Python is a language that uses indentations to denote code blocks. This code will convert a decimal to binary. Now, note that the range start of 8 gives you a hint about the upper bound of the number that the code can translate. Therefore, an if condition must be added after the second statement to ensure we are not attempting to convert a number that is too large. Enjoy!






share|improve this answer


























  • Okay. I decided to debug the program for you. Please see the edited response above :-)

    – faris
    Nov 14 '18 at 14:10











  • Thank you i will try it

    – Diamonddeo
    Nov 14 '18 at 14:18











  • It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

    – Diamonddeo
    Nov 14 '18 at 14:22













  • You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

    – faris
    Nov 14 '18 at 14:44











  • thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

    – Diamonddeo
    Nov 14 '18 at 15:01
















0














From a quick inspection, range(100,0), B, and Print() are three culprits here! If you want to pass through numbers from 0 to 99, then range(100) is what you need. Now, what is B? Print should be written in lower case: print.



After we fix these syntax errors, let us try to revisit the program and understand what it is supposed to do. Have fun :-)



EDIT to fix the code in the question:



E = input('Please enter a number: ') 
Eint = int(E)
for N in range(8,-1,-1):
if 2**N > Eint:
print(0, end='')
else:
Eint = Eint - 2**N
print(1, end='')

print()
print('finished')


Please note that Python is a language that uses indentations to denote code blocks. This code will convert a decimal to binary. Now, note that the range start of 8 gives you a hint about the upper bound of the number that the code can translate. Therefore, an if condition must be added after the second statement to ensure we are not attempting to convert a number that is too large. Enjoy!






share|improve this answer


























  • Okay. I decided to debug the program for you. Please see the edited response above :-)

    – faris
    Nov 14 '18 at 14:10











  • Thank you i will try it

    – Diamonddeo
    Nov 14 '18 at 14:18











  • It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

    – Diamonddeo
    Nov 14 '18 at 14:22













  • You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

    – faris
    Nov 14 '18 at 14:44











  • thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

    – Diamonddeo
    Nov 14 '18 at 15:01














0












0








0







From a quick inspection, range(100,0), B, and Print() are three culprits here! If you want to pass through numbers from 0 to 99, then range(100) is what you need. Now, what is B? Print should be written in lower case: print.



After we fix these syntax errors, let us try to revisit the program and understand what it is supposed to do. Have fun :-)



EDIT to fix the code in the question:



E = input('Please enter a number: ') 
Eint = int(E)
for N in range(8,-1,-1):
if 2**N > Eint:
print(0, end='')
else:
Eint = Eint - 2**N
print(1, end='')

print()
print('finished')


Please note that Python is a language that uses indentations to denote code blocks. This code will convert a decimal to binary. Now, note that the range start of 8 gives you a hint about the upper bound of the number that the code can translate. Therefore, an if condition must be added after the second statement to ensure we are not attempting to convert a number that is too large. Enjoy!






share|improve this answer















From a quick inspection, range(100,0), B, and Print() are three culprits here! If you want to pass through numbers from 0 to 99, then range(100) is what you need. Now, what is B? Print should be written in lower case: print.



After we fix these syntax errors, let us try to revisit the program and understand what it is supposed to do. Have fun :-)



EDIT to fix the code in the question:



E = input('Please enter a number: ') 
Eint = int(E)
for N in range(8,-1,-1):
if 2**N > Eint:
print(0, end='')
else:
Eint = Eint - 2**N
print(1, end='')

print()
print('finished')


Please note that Python is a language that uses indentations to denote code blocks. This code will convert a decimal to binary. Now, note that the range start of 8 gives you a hint about the upper bound of the number that the code can translate. Therefore, an if condition must be added after the second statement to ensure we are not attempting to convert a number that is too large. Enjoy!







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 14:13

























answered Nov 14 '18 at 13:34









farisfaris

165




165













  • Okay. I decided to debug the program for you. Please see the edited response above :-)

    – faris
    Nov 14 '18 at 14:10











  • Thank you i will try it

    – Diamonddeo
    Nov 14 '18 at 14:18











  • It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

    – Diamonddeo
    Nov 14 '18 at 14:22













  • You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

    – faris
    Nov 14 '18 at 14:44











  • thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

    – Diamonddeo
    Nov 14 '18 at 15:01



















  • Okay. I decided to debug the program for you. Please see the edited response above :-)

    – faris
    Nov 14 '18 at 14:10











  • Thank you i will try it

    – Diamonddeo
    Nov 14 '18 at 14:18











  • It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

    – Diamonddeo
    Nov 14 '18 at 14:22













  • You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

    – faris
    Nov 14 '18 at 14:44











  • thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

    – Diamonddeo
    Nov 14 '18 at 15:01

















Okay. I decided to debug the program for you. Please see the edited response above :-)

– faris
Nov 14 '18 at 14:10





Okay. I decided to debug the program for you. Please see the edited response above :-)

– faris
Nov 14 '18 at 14:10













Thank you i will try it

– Diamonddeo
Nov 14 '18 at 14:18





Thank you i will try it

– Diamonddeo
Nov 14 '18 at 14:18













It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

– Diamonddeo
Nov 14 '18 at 14:22







It worked ! thank you very much ah ah,now i will waste your time a little bit if you're okay. could you explain why did you wrote (end=' ') and why is there two print at the end ^^

– Diamonddeo
Nov 14 '18 at 14:22















You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

– faris
Nov 14 '18 at 14:44





You are welcome! The end='' keeps the printed text on the same line. The extra print() statement is to print the word "finished" on a new line. Try to remove these lines to see what you get. Programming is fun. :-)

– faris
Nov 14 '18 at 14:44













thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

– Diamonddeo
Nov 14 '18 at 15:01





thank you for your eplanations. I really love programmation that's why in my Highschool i choosen I.S.N (that is computer science in french) and later i would like to work as an computer engineer :)

– Diamonddeo
Nov 14 '18 at 15:01













0














If it helps check my solution too. Because I guess you don't want to see the result on separate lines, so I create a list for you to see the result in one line.



E = int(input('Please enter a numbern'))
Eint = E
base_two=
while E > 0:
a = int(float(E%2))
base_two.append(a)
E = (E-a)/2
base_two.append(0)
string = ""
for j in base_two[::-1]:
string = string+str(j)
print("Binary for", Eint, "is", string)
print('finished')


I was late a little bit :)






share|improve this answer


























  • Thank you for your help ! it's working so good ah ah

    – Diamonddeo
    Nov 14 '18 at 14:31
















0














If it helps check my solution too. Because I guess you don't want to see the result on separate lines, so I create a list for you to see the result in one line.



E = int(input('Please enter a numbern'))
Eint = E
base_two=
while E > 0:
a = int(float(E%2))
base_two.append(a)
E = (E-a)/2
base_two.append(0)
string = ""
for j in base_two[::-1]:
string = string+str(j)
print("Binary for", Eint, "is", string)
print('finished')


I was late a little bit :)






share|improve this answer


























  • Thank you for your help ! it's working so good ah ah

    – Diamonddeo
    Nov 14 '18 at 14:31














0












0








0







If it helps check my solution too. Because I guess you don't want to see the result on separate lines, so I create a list for you to see the result in one line.



E = int(input('Please enter a numbern'))
Eint = E
base_two=
while E > 0:
a = int(float(E%2))
base_two.append(a)
E = (E-a)/2
base_two.append(0)
string = ""
for j in base_two[::-1]:
string = string+str(j)
print("Binary for", Eint, "is", string)
print('finished')


I was late a little bit :)






share|improve this answer















If it helps check my solution too. Because I guess you don't want to see the result on separate lines, so I create a list for you to see the result in one line.



E = int(input('Please enter a numbern'))
Eint = E
base_two=
while E > 0:
a = int(float(E%2))
base_two.append(a)
E = (E-a)/2
base_two.append(0)
string = ""
for j in base_two[::-1]:
string = string+str(j)
print("Binary for", Eint, "is", string)
print('finished')


I was late a little bit :)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 16:56

























answered Nov 14 '18 at 14:28









AhmetAhmet

13




13













  • Thank you for your help ! it's working so good ah ah

    – Diamonddeo
    Nov 14 '18 at 14:31



















  • Thank you for your help ! it's working so good ah ah

    – Diamonddeo
    Nov 14 '18 at 14:31

















Thank you for your help ! it's working so good ah ah

– Diamonddeo
Nov 14 '18 at 14:31





Thank you for your help ! it's working so good ah ah

– Diamonddeo
Nov 14 '18 at 14:31


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301293%2fpython-not-running-my-program-without-any-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues