Python Infosys Question
Python Infosys Question
output:
output:
• Write a program to print this series
1 1 2 3 5 8 13
def fibonacci_series(n):
fib_series = [1, 1]
output:
An organization has decided to provide salary
hike to its employees based on their job level.
Employees can be in job levels 3 , 4 or 5. Hike
percentage based on job levels are given below:
Job level
Hike Percentage (applicable on current salary)
# Example usage:
current_salary = float(input("Enter the current salary: "))
job_level = int(input("Enter the job level (3, 4, or 5): "))
new_salary = calculate_new_salary(current_salary, job_level)
print("The new salary of the employee is:", new_salary)
output :
Write a Python Function is_palindrome(num)
that accepts an integer num as argument and
returns True if the num is palindrome else
returns false. Invoke the function and based on
return value print the output.
def is_palindrome(num):
num_str = str(num)
if num_str == num_str[::-1]:
return True
else:
return False
num = int(input("Enter an integer: "))
if is_palindrome(num):
print(num, "is a palindrome.")
else:
print(num, "is not a palindrome.")
Write a Python function
check_amicable_numbers(num1, num2) that
accepts two numbers num1 and num2 as
arguments and returns True if the given pair of
numbers are amicable numbers else return
false. Invoke the function and based on return
value print the numbers are amicable numbers
or not.
def sum_of_divisors(n):
divisor_sum = 0
for i in range(1, n):
if n % i == 0:
divisor_sum += i
return divisor_sum
if check_amicable_numbers(num1, num2):
print(num1, "and", num2, "are amicable numbers.")
else:
print(num1, "and", num2, "are not amicable numbers.")
rotated_value = right_shift(num, n)
print("The value after right shift rotation by", n, "positions is:",
rotated_value)
Write a Python function proper_divisors(num)
which returns a list of all the proper divisors of
given number.
def proper_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors
num = int(input("Enter a number to find its proper divisors: "))
divisors_list = proper_divisors(num)
print("Proper divisors of", num, "are:", divisors_list)
encoded_message = ""
count = 1
prev_char = message[0]
return counts
input_sentence = input("Enter a sentence: ")
result = vowel_count(input_sentence)
print("Count of vowels, consonants, and other characters:", result)