Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def decToOctal(decimal):#פונקציה להפיכת מספר עשרוני למספר אוקטלי
- octal = 0
- ctr = 0
- temp = decimal # copying number
- # computing octal using while loop
- while (temp > 0):
- octal += ((temp % 8) * (10 ** ctr)) # Stacking remainders
- temp = int(temp / 8) # updating dividend
- ctr += 1
- return octal
- def OctalToDecimal(num): #פונקציה להפיכת מספר אוקטלי למספר עשרוני
- decimal = 0
- base = 1 #Initializing base value to 1, i.e 8^0
- while (num):
- # Extracting last digit
- last_digit = num % 10
- num = int(num / 10)
- decimal += last_digit * base
- base = base * 8
- return decimal
- def numbers_methods():
- DecimalList =[]
- OctalList = []
- sum=0
- for i in range(3):
- number = int(input("enter a octal number"))
- DecimalList.append(OctalToDecimal(number))
- OctalList.append(number)
- sum += OctalToDecimal(number)
- print("the octal numbers is: ", OctalList)
- print("the decimal numbers is : ", DecimalList)
- print("the sum of decimal number is : ",sum," --- in Octal is: ",decToOctal(sum))
- def summer(list1):
- mystring=""
- newList = []
- for i in range(len(list1)):
- if(type(list1[i]) == int or type(list1[i]) == float):#בדיקה
- return sum(list1)
- elif(type(list1[i]) == bool):
- return (sum(list1))
- elif(type(list1[i]) == str):
- mystring += list1[i]
- elif(type(list1) == list):
- newList = list1
- return newList
- return mystring
- def main():
- #numbers_methods()
- print(summer([10,11,12,0.75]))
- print(summer([True,False,True,True]))
- print(summer(['aa','bb','cc']))
- print(summer([[1,2,3,'a'],['a','b','c',4]]))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement