Sunday, 20 December 2020

Python : Calulator

 import math



def add(a, b):
return a + b


def Sub(a, b):
return a - b


def Mul(a, b):
return a * b


def div(a, b):
return a / b


print("Please select operation -\n" \
"1. add \n" \
"2. sub \n" \
"3.mul \n" \
"4. div")

Select = int(input("Select operation form list 1 2 3 4:"))

Number_1 = int(input("Enter First Number :"))
number_2 = int(input("Enter 2nd number:"))


if Select == 1:
print(Number_1, number_2, add(Number_1, number_2))


if Select == 2:
print(Number_1, number_2, Sub(Number_1, number_2))


if Select == 3:
print(Number_1, number_2, Mul(Number_1, number_2))

if Select == 4:
print(Number_1, number_2, div(Number_1, number_2))

else:
print("Invalid Entry")

Tuesday, 4 August 2020

Find the Runner-Up Score!


Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given  scores. Store them in a list and find the score of the runner-up.

Input Format

The first line contains . The second line contains an array   of  integers each separated by a space.

Constraints

Output Format

Print the runner-up score.

Sample Input 0

5
2 3 6 6 5

Sample Output 0

5

Explanation 0

Given list is . The maximum score is , second maximum is . Hence, we print  as the runner-up score.





if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
arr =list(arr)
arr.sort(reverse = True)
arr =  [i for i in arr if i != max(arr)]
print(max(arr))

Tuesday, 3 March 2020

String Characteristics

String Characteristics:
  • It is a reference type.
  • It’s immutable( its state cannot be altered).
  • It can contain nulls.
  • It overloads the operator(==).

Different Ways for Creating a String:
  • Create a string from a literal
  • Create a string using concatenation
  • Create a string using a constructor
  • Create a string using a property or a method
  • Create a string using formatting