File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
HackInScience/Beginner_Exercises Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ def longest_word (text ):
2
+ word = text .split ()
3
+ longestWord = "0"
4
+ if len (word ):
5
+ for i in word :
6
+ if len (i ) > len (longestWord ):
7
+ longestWord = i
8
+ else :
9
+ longestWord = None
10
+
11
+ return longestWord
12
+
Original file line number Diff line number Diff line change
1
+ # Provide a script printing every possible pairs of two letters,
2
+ # only lower case, one by line, ordered alphabetically.
3
+
4
+ import string
5
+
6
+ # Print Every Possible letter pairs
7
+ def printLetterPairs ():
8
+ letters = string .ascii_lowercase
9
+
10
+ for i in letters :
11
+ for b in letters :
12
+ print (i + b )
13
+
14
+ def printDistinctPairs ():
15
+ lowerCase_letter = string .ascii_lowercase
16
+ for i in lowerCase_letter :
17
+ for b in lowerCase_letter :
18
+ if i != b :
19
+ print (i + b )
Original file line number Diff line number Diff line change
1
+ # Write functions to convert from Fahrenheit to Celsius and vice-versa.
2
+
3
+ from time import process_time_ns
4
+
5
+
6
+ def fahrenheit_to_celsius (temp ):
7
+ F = temp
8
+ C = (F - 32 ) * 5 / 9
9
+ return C
10
+
11
+ def celsius_to_fahrenheit (temp ):
12
+ C = temp
13
+ F = (C * 9 / 5 ) + 32
14
+ return F
15
+
16
+ print (fahrenheit_to_celsius (98.6 ))
17
+ print (celsius_to_fahrenheit (26 ))
You can’t perform that action at this time.
0 commit comments