code
stringclasses
7 values
text
stringclasses
7 values
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for converting kilometers to miles
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for converting kilometers to miles
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is responsible for converting kilometers to miles
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This code is responsible for checking if an element exists in a list
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
This code is responsible for checking if an element exists in a list
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for converting kilometers to miles
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for converting kilometers to miles
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the factorial of a number
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This code is responsible for checking if an element exists in a list
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is responsible for converting kilometers to miles
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the factorial of a number
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is useful for checking if a particular string is palindrome or not
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the factorial of a number
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, area of the triangle is calculated when three sides are given using Herons formula.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for converting kilometers to miles
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This code is responsible for checking if an element exists in a list
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for converting kilometers to miles
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is responsible for finding the factorial of a number
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
This program is useful for checking if a particular string is palindrome or not
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
This code is responsible for checking if an element exists in a list
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This code is responsible for checking if an element exists in a list
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is responsible for converting kilometers to miles
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is useful for checking if a particular string is palindrome or not
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for finding the factorial of a number
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This code is responsible for checking if an element exists in a list
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
In this program, area of the triangle is calculated when three sides are given using Herons formula.
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This code is responsible for checking if an element exists in a list
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is useful for checking if a particular string is palindrome or not
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the factorial of a number
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for converting kilometers to miles
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This code is responsible for checking if an element exists in a list
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for converting kilometers to miles
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is responsible for finding the factorial of a number
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is responsible for converting kilometers to miles
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This program is responsible for converting kilometers to miles
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python3 program to swap first # and last element of a list # Swap function def swapList(newList): size = len(newList) # Swapping temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList # Driver code newList = [12, 35, 9, 56, 24] print(swapList(newList))
This code is responsible for checking if an element exists in a list
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
In this program, area of the triangle is calculated when three sides are given using Herons formula.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This code is responsible for checking if an element exists in a list
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is responsible for finding the factorial of a number
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Python Program to find the area of triangle a = 5 b = 6 c = 7 # Uncomment below to take inputs from the user # a = float(input('Enter first side: ')) # b = float(input('Enter second side: ')) # c = float(input('Enter third side: ')) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area)
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is responsible for finding the factorial of a number
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, area of the triangle is calculated when three sides are given using Herons formula.
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is responsible for finding the length of the list and swap the first element with (n-1)th element.
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
In this program, area of the triangle is calculated when three sides are given using Herons formula.
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
In this program, area of the triangle is calculated when three sides are given using Herons formula.
lst=[ 1, 6, 3, 5, 3, 4 ] #checking if element 7 is present # in the given list or not i=7 # if element present then return # exist otherwise not exist if i in lst: print("exist") else: print("not exist")
This program is useful for checking if a particular string is palindrome or not
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
This program is useful for checking if a particular string is palindrome or not
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
In this program, we use the temp variable to hold the value of x temporarily. We then put the value of y in x and later temp in y. In this way, the values get exchanged.
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
This program is responsible for finding the factorial of a number
# function which return reverse of a string def isPalindrome(s): return s == s[::-1] # Driver code s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No")
This program is responsible for finding the factorial of a number
# Python 3 program to find # factorial of given number def factorial(n): # single line to find factorial return 1 if (n==1 or n==0) else n * factorial(n - 1) # Driver Code num = 5 print("Factorial of",num,"is",factorial(num))
This program is useful for checking if a particular string is palindrome or not
# Python program to swap two variables x = 5 y = 10 # To take inputs from the user #x = input('Enter value of x: ') #y = input('Enter value of y: ') # create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))
This program is useful for checking if a particular string is palindrome or not
# Taking kilometers input from the user kilometers = float(input("Enter value in kilometers: ")) # conversion factor conv_fac = 0.621371 # calculate miles miles = kilometers * conv_fac print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
This program is responsible for converting kilometers to miles