473,661 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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
2 1511
bvdet
2,851 Recognized Expert Moderator Specialist
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
dasazzad
2 New Member
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
4956
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 integers. My code is listed below, but the problem is that my output of sum is wrong. For example, I am using 1347830 for my integers and the program outputs 373 and after adding 373 you should get 13 for the total, but that doesn't happen. Any help...
16
660
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 brain got stuck on it..sorry! Hi: I need some help writing code that will "print" a report using Cute PDF.
2
2840
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 message: "AttributeError: OutputBinary." Here is my code below: Please Help.
11
5030
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 debug it let me narrow the problem down to the Cipher function I think it faults at line 84 or 85. The program makes it's first read/cipher/write pass without issue but the second pass kills it. Using gdb to print the variables left showed me the...
0
1271
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 INTERFACE_TYPE_ATTRIBUTES = TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract | TypeAttributes.AutoClass |
0
2365
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 btnprint,btnclose
2
9940
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
6458
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 in it like Swap) and build them. Now I again make another project hello in which i make a file main.c in which I included lib1.h. When i tried to run the program i got the message "please select the host to run the library" something like that. Then...
1
2163
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” command? In any application print command, there are two options: 1. Quick print..immediately prints using default printer 2. Print.. Gives more print options I want to add the 2nd option in the pop up menu when right clicked on the report....
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7364
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.