Why output is r ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 54

Why output is r ?

print(max("Sololearn")) https://ibb.co/C8kPByg

6th Jun 2020, 11:42 AM
Simba
Simba - avatar
31 Answers
+ 26
6th Jun 2020, 11:54 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 26
Gaurav Dixit 🇮🇳 Namit Jain Kuba Siekierzyński Jyoti Rani Thank you friends. Now I am clear😊
6th Jun 2020, 12:03 PM
Simba
Simba - avatar
+ 12
If you see the ASCII values of all the letters in SoloLearn then you will see that the 'r' comes the last: You can remember ascii in this way: 65-90 -> capital letters (A,B,C,D......) 97-122 -> lowercase letters (a,b,c,d.....) 49-58 -> numbers (1,2,3,4......) So if it was 'sololearn' then the highest value would be 's'
6th Jun 2020, 11:52 AM
Namit Jain
Namit Jain - avatar
+ 12
Gaurav Dixit 🇮🇳 I know that, I just gave him an example that if 's' was in lowercase then the answer would have been 's' instead of 'r'
6th Jun 2020, 12:01 PM
Namit Jain
Namit Jain - avatar
+ 11
Kuba Siekierzyński 👏👏👏👍👍👍 32 -> ' ' (space) Try this: chr(83) + chr(105) + chr(109) + chr(98) + chr(97) output: Simba In order to find out tge ascii value of any letter: print(ord('S')) output: 83
6th Jun 2020, 11:59 AM
Namit Jain
Namit Jain - avatar
+ 9
Simba it's take max of ASCII code
6th Jun 2020, 11:45 AM
Gaurav Dixit🇮🇳
Gaurav Dixit🇮🇳 - avatar
+ 9
Gaurav Dixit 🇮🇳 you're correct. But it's working now✌
8th Jun 2020, 4:00 AM
Simba
Simba - avatar
+ 8
Namit Jain In question S is capital bro read question carefully
6th Jun 2020, 11:56 AM
Gaurav Dixit🇮🇳
Gaurav Dixit🇮🇳 - avatar
+ 8
It is taking ascii value of every character. Ascii value 'S' and 'L' in SoloLearn are 83 nd 76. All other characters in small letter are having more ascii value than S nd L. Among 'oloearn' ascii value of "r" is max.
6th Jun 2020, 12:00 PM
Jyoti Rani
Jyoti Rani - avatar
8th Jun 2020, 8:32 AM
Simba
Simba - avatar
+ 6
The Ascii value of small letters is greater than that of capital letters So the Ascii vaue of r is greater than S Hence the max returns the value r as output
8th Jun 2020, 7:25 AM
Akshay Panwar
Akshay Panwar - avatar
8th Jun 2020, 8:48 AM
Simba
Simba - avatar
+ 5
The answer is r and the reason is because the position python is in using the max () function returns the largest element in an iterable. But it can also be used to find the largest element between two or more parameters and that is why in the word "SoloLearn" by searching in it using the max () function find the character that has the assignment in ascii is "r" when comparing among others. r has the highest value S = 83 o = 111 l = 108 o = 111 L = 76 e = 101 a = 97 r = 114 n = 110
12th Jun 2020, 12:44 AM
Sidhartha Manríquez
Sidhartha Manríquez - avatar
+ 4
Ascii for Capital letters start from 65 And for small letters it starts from 97
8th Jun 2020, 7:26 AM
Akshay Panwar
Akshay Panwar - avatar
+ 3
I am not able to understand answer is "S" or "r"
8th Jun 2020, 8:35 AM
Arctic Fox
Arctic Fox - avatar
8th Jun 2020, 8:44 AM
Simba
Simba - avatar
+ 2
Simba also your app is not working
8th Jun 2020, 1:58 AM
Gaurav Dixit🇮🇳
Gaurav Dixit🇮🇳 - avatar
+ 2
somya darshi patra 's' is in capital letter see carefully ('S')
8th Jun 2020, 3:15 AM
Jyoti Rani
Jyoti Rani - avatar
+ 2
In this question ascii value of r is higher thats way the answer will be (r).🤗
8th Jun 2020, 8:05 AM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
+ 2
I anyone satisfied with my reason then give me up vote
8th Jun 2020, 8:07 AM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar