diff --git a/Basics/greet.py b/Basics/greet.py index aa0c635..2158d7d 100644 --- a/Basics/greet.py +++ b/Basics/greet.py @@ -1,7 +1,8 @@ #This programs says hello and asks for a name and greets the user -print("Hello,There") +print("Hello,There...") -Uname = input("Please,Enter your sweet Name:") #taking input(user name) from the user +Uname = input("Please,Enter your sweet Name:") #taking name from the user print("It's nice to meet you,"+ Uname) #printing the greeting output +print("Welcome to the Python world") diff --git a/Coding Questions/prgm-1.py b/Coding Questions/prgm-1.py new file mode 100644 index 0000000..ae19d52 --- /dev/null +++ b/Coding Questions/prgm-1.py @@ -0,0 +1,26 @@ +# A program to find the short form of a given word in a specific format.The conditions are given below +# Adjacent letters of a string are paired.From each pair one letter is selected +# The letter with highest ascii value is selected +# The letter is stored into str1 variable +# If a pair cannot be formed, then the last letter is added to str1 + + + + +x = input() +n = len(x) +#print(n) +#print(ord(x[0])) +str1 = '' +for i in range(0,n,2): + if(i+1 < n): + if(ord(x[i]) > ord(x[i+1])): + str1 = str1 + x[i] + elif(ord(x[i]) < ord(x[i+1])): + str1 = str1 + x[i+1] + elif(ord(x[i]) == ord(x[i+1])): + str1 = str1 + x[i] + else: + str1 = str1 + x[n-1] +print(str1) +