473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

I was trying to print a simple number using this code: " print ("Test output %d" %

Hello there,

I was trying to print a simple number using this code:

" print ("Test output %d" % 050) "

but it is giving following output

" Test output 40 "

I need this explanation why it is showing this result.

In Fact I've tried with few more code and the respective output is given below with the code.. Please Help me with the explanation..

Sample 1:
print ("Test Output %d" % 0100)
Test Output 64

Sample 2:
print ("Test Output %d" % 060)
Test Output 48

Sample 3:
print ("Test Output %d" % 020)
Test Output 16

Sample 4:
print ("Test Output %d" % 010)
Test Output 8

Sample 5: (It actually provide error)
print ("Test Output %d" % 080)
output:
print ("Test Output %d" % 080)
^
SyntaxError: invalid token
Jan 21 '16 #1

✓ answered by bvdet

The integer "050" is in octal notation and represents the decimal integer "40". "080" is invalid because there is no "8" in octal.
Examples of octal, hexidecimal and binary numeric literals:
Expand|Select|Wrap|Line Numbers
  1. >>> 050
  2. 40
  3. >>> 080
  4. Traceback (  File "<interactive input>", line 1
  5.     080
  6.       ^
  7. SyntaxError: invalid token
  8. >>> 0x659def
  9. 6659567
  10. >>> 0b1001100011010
  11. 4890
  12. >>> 

2 1504
bvdet
2,851 Expert Mod 2GB
The integer "050" is in octal notation and represents the decimal integer "40". "080" is invalid because there is no "8" in octal.
Examples of octal, hexidecimal and binary numeric literals:
Expand|Select|Wrap|Line Numbers
  1. >>> 050
  2. 40
  3. >>> 080
  4. Traceback (  File "<interactive input>", line 1
  5.     080
  6.       ^
  7. SyntaxError: invalid token
  8. >>> 0x659def
  9. 6659567
  10. >>> 0b1001100011010
  11. 4890
  12. >>> 
Jan 21 '16 #2
Thank you Mr. Bvdet that was helpful.
Jan 24 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: hoover_richard | last post by:
I am a newbie to C++ and I need help with a simple program I am trying to write. My program is designed to print all of the odd integers contained in an array and output the sum of the odd...
16
by: John Baker | last post by:
HI; I feel like a fool..I put CUTE FTP in my last request for help --it should have been CUTE PDF! I have FTP on my mind because I have been working on a web based application, and somehow my...
2
by: kbperry | last post by:
Hi all, I am getting an error message when trying to use the P4 print command via the python api for perforce. Anytime that I run p4c.run("print","-q", eachFile), I keep getting an error...
11
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to...
0
by: hypeartist | last post by:
I need to create interface "on-the-fly" so it "reflects" some class (mainly it's properties). Here's how I do this: public class Transformer { private const TypeAttributes...
0
by: thirunavukarasukm | last post by:
Hai.... To print Html page using PrintDialog and Print Document i am created one windows appication.. the windows application have many pages in my booking page i have two buttons one...
2
by: Josephbupe | last post by:
Instead of going to file>Print, i need a form with a "print" command button to print reports that have been queried. What code and how is it used for this. I will appreciate. Regards.
5
by: puneetsardana88 | last post by:
Hi I tried to make a library using code blocks. For which I went file->new->project->static library and name it as mylib and then i created a file mylib1.c and mylib1.h (with some sample functions...
1
Jerry Maiapu
by: Jerry Maiapu | last post by:
I have these customer pop up menu for a report. I have added the print command to the custome pop up menu but when clicked it prints away directly. How can I add the “print options dialogue box”...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.