This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int binaryToDecimal (int binaryNumber){ | |
int digitIndex; | |
int decimalNum = 0; | |
int powerIndex = 0; | |
while(( binaryNumber != 0) && ( binaryNumber >0)){ | |
digitIndex = binaryNumber % 10; | |
decimalNum = decimalNum + (int)(Math.pow(2,powerIndex) * digitIndex); | |
binaryNumber = binaryNumber / 10; | |
powerIndex++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
while True: | |
if (random.randint(1,2) == 1): | |
print("Right") | |
#print(random_number) | |
input("hit enter for next") | |
if (random.randint(1,2) == 2): | |
print("Left") | |
#print(random_number) | |
input("hit enter for next") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input("enter triangle number")) | |
ini = 10 | |
for x in range(1,n+1): | |
if (x==1): | |
print (1) | |
else: | |
ini = ini * 10 | |
print (ini) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
print("This program splits the seconds you enter into Days:Hours:Minutes:Seconds") | |
n = int(input("enter seconds")) | |
days = n // (24*60*60) | |
days_rem = n %(24*60*60) | |
hours = days_rem // (60*60) | |
hours_rem = days_rem % (60*60) | |
minutes = hours_rem//60 | |
seconds = hours_rem%60 | |
NewerOlder