-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitscalc.py
More file actions
32 lines (27 loc) · 773 Bytes
/
bitscalc.py
File metadata and controls
32 lines (27 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Bits Calc ##
## Author: Abueesp ##
## Date: Tue, May 23 2015 ##
## License: CC NC-BY-SA ##
scriptname = 'Bits Calc'
prompt = '> '
print "Hello, I'm the", scriptname, "a pretty dumb code for calculating bits"
print "Introduce the number of bits: "
bits = int(raw_input(prompt))
bytes= bits/8
print "You have", bits, "bits, which are", bytes, "words of 8-bits also known as bytes."
print "\n"
print "Which represent the following bit positions"
if (bits % 2 == 0):
for i in range(bits/2):
print 1,
elif(bits % 2 == 1):
for i in range((bits-1)/2):
print 1,
print 0
else:
print 'Was that a number?'
print "\n"
possibilities=2**bits
dualities=possibilities/2
print "Which represent", possibilities, "possibilities, or", dualities, "dualities."
print "\n"