Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Test123/Add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Author: OMKAR PATHAK
# This program prints the entered message

def justPrint(text):
'''This function prints the text passed as argument to this function'''
print(text)
a=int(input("Enter a number: "))
b=int(input("Enter another number: "))
increment_value = a + b
print("The sum of the two numbers is:", increment_value)

if __name__ == '__main__':
justPrint('Hello Sindhuja')


17 changes: 17 additions & 0 deletions Test123/Factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Author: OMKAR PATHAK
#This program finds the favtorial of the specified numbers
#For example, factorial of 5 = 5*4*3*2*1 = 120

def factorial(number):
'''This function finds the factorial of the number passed as argument'''
if number < 0:
print('Invalid entry! Cannot find factorial of a negative number')
if number == 0 or number == 1:
print("Hello")
return 1
else:
return number * factorial(number - 1)

if __name__ == '__main__':
userInput = int(input('Enter the Number to find the factorial of: '))
print(factorial(userInput))
14 changes: 14 additions & 0 deletions Test123/P13_Palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Author: OMKAR PATHAK
#This program checks for the palindrome

def palindrome(string):
'''This function checks the string for palindrome'''
revString = string[::-1]
if string == revString:
print('String is Palindrome')
else:
print('String is not Palindrome')

if __name__ == '__main__':
userInput = str(input('Enter a string to check for Palindrome: '))
palindrome(userInput)
15 changes: 15 additions & 0 deletions Test123/P14_CheckGreater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Author: OMKAR PATHAK
#This prpgram checks that the given number is greater than all those numbers in th list

def checkGreater(number):
'''This function checks whether the entered number is greater than those in the list'''
original = [1,2,3,4,5]
original.sort()
if number > original[-1]:
print('Yes, the entered number is greater than those in the list')
else:
print('No, entered number is less than those in the list')

if __name__ == '__main__':
userInput = int(input('Enter the number to check: '))
checkGreater(userInput)
17 changes: 17 additions & 0 deletions Test123/P15_Arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Author: OMKAR PATHAK
#This program gives a demo of how can you pass arguments while running python programs
#Run the program as: python P15_Arguments.py Omkar Pathak

import sys

def arguments():
'''This function prints the argruments passed while running the python program'''
try:
print('This is the name of the script:', sys.argv[0])
print('First argument:', sys.argv[1])
print('Second argument:', sys.argv[2])
except IndexError:
print('Give only two arguments')

if __name__ == '__main__':
arguments()
17 changes: 17 additions & 0 deletions Test123/P16_CountVowels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Author: OMKAR PATHAK
#This program counts the vowels present in the user input

def countVowels(sentence):
'''This function counts the vowels'''
count = 0
sentence = sentence.lower()
for c in sentence:
if c in ['a', 'e', 'i', 'o', 'u']:
count += 1
return count


if __name__ == '__main__':
userInput = str(input("Enter the string to check for vowels: "))
count = countVowels(userInput)
print('Vowel Count: ',count)
19 changes: 19 additions & 0 deletions Test123/P17_EvenOdd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Author: OMKAR PATHAK
#This program takes input from user and sorts the numbers in two arrays, one of even and other of odd

def evenOdd(numbers):
'''This function divides the numbers in two arrays one of even and other of odd'''
even = []
odd = []
for number in numbers:
if int(number) % 2 == 0:
even.append(number)
else:
odd.append(number)
return even, odd

if __name__ == '__main__':
userInput = input("Enter the numbers (space separated) to check: ")
userInput = list(userInput.split())
even, odd = evenOdd(userInput)
print('Even Nos: ', ','.join(even), '\n', 'Odd Nos: ', ','.join(odd))
Loading