예제 #1
0
import numbers

print(numbers.factorial(5))
예제 #2
0
                )
                armstrong_Input = int(input("\nEnter the value:"))
                numbers.armstrong(armstrong_Input)
            elif Number_Input == "14":
                print(
                    "\n\n UserGuide : Fibonacci function:returns the Fibonacci series"
                )
                Fibonacci_Input = int(input("\nEnter the value:"))
                numbers.Fibonacci(Fibonacci_Input)
            elif Number_Input == "15":
                print(
                    "\n\n UserGuide : factorial function:returns the factorial number"
                )
                factorial_Input = int(input("\nEnter the value:"))
                print("The factorial of given number :",
                      numbers.factorial(factorial_Input))
            elif Number_Input == "16":
                print(
                    "\n\n UserGuide : odd_even function:returns the value is odd or even"
                )
                odd_even_Input = int(input("\nEnter the  value:"))
                numbers.odd_even(odd_even_Input)
            elif Number_Input == "17":
                print(
                    "\n\n UserGuide : Postive_Negative function:returns the value is Positive or Negative"
                )
                Postive_Negative_Input = int(input("\nEnter the value:"))
                numbers.Postive_Negative(Postive_Negative_Input)

            else:
                print("Exiting...")
예제 #3
0
파일: main.py 프로젝트: ICafer/basicpython
#Import บางฟังก์ชันใน Module แบบต้องระบุเอาเฉพาะตัว
from numbers import factorial, fibonacci

#เรียกใช้งาน
print(factorial(5))
print(fibonacci(100))

#-------------------------------------------------

#Import บางฟังก์ชันใน Module แบบไม่ต้องระบุเอาเฉพาะตัว
from numbers import *

#เรียกใช้งาน
print(factorial(6))
print(fibonacci(200))

#-------------------------------------------------

#import และเปลี่ยนชื่อฟังก์ชัน (นามแฝง) alias
from numbers import factorial as fa, fibonacci as fi

#เรียกใช้งาน
print(fa(7))
print(fi(300))

#-------------------------------------------------

#Import ทั้งหมดทุกฟังก์ชันใน Module
import numbers

#เรียกใช้งาน
예제 #4
0
    pick = int(input("Please enter your choice:"))

    if pick == 1:
        numbers.sum()
    elif pick == 2:
        numbers.difference()
    elif pick == 3:
        numbers.product()
    elif pick == 4:
        numbers.power()
    elif pick == 5:
        numbers.squareroot()
    elif pick == 6:
        numbers.cuberoot()
    elif pick == 7:
        numbers.factorial()
    elif pick == 8:
        numbers.printTable()

elif choice == 2:
    print("1. Reverse string")
    print("2. Print alphabet of strings")
    print("3. Slice a string")
    print("4. Check string for a palindrome")
    print("5. captal case string")
    print("6. Small case a string")
    print("7. Count numbers of characters in string")


예제 #5
0
def factorial(n):  # return factorial value of n
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 4)
예제 #6
0
from numbers import factorial, fibonacci


def factorial(n):  # return factorial value of n
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 4)


print(factorial(5))
print(fibonacci(5))
예제 #7
0
 def test_factorial(self):
     self.assertEqual(1, numbers.factorial(1))
     self.assertEqual(2, numbers.factorial(2))
     self.assertEqual(6, numbers.factorial(3))
     self.assertEqual(120, numbers.factorial(5))
     self.assertEqual(720, numbers.factorial(6))
예제 #8
0
def sum_of_digits_of_factorial(n):
    return sum_of_digits(numbers.factorial(n))