33
loading...
This website collects cookies to deliver better user experience
try
catch
statements, and basic exception handling. Advanced exception handling and types of exceptions, user defined exceptions is for later.try
catch
and learnt about nesting them. We also saw one really challenging question related to try
except
here.try
except
. We covered questions like fractal lists, alphabetical order of lists and reversing lists.a=[1,4,3,5,2]
for i in range(1, len(a)):
#key = a[i]
for j in range(0,i):
if(a[j]<a[i]):
(a[j],a[i])=(a[i],a[j])#swap
print(a)
'''
Logic-
Set the key equal to the first unsorted value.
Compare the key and the sorted elements.
Move the key to the required position.
'''
[5, 4, 3, 2, 1]
'''
is block comments. Whenever working in teams, such documentation is of critical. More about it here.For those who are new to Data structures and algorithms, please check out this course on dev.to.-Data structure & algorithms Series' Articles
a=[]
for i in range(0,4):
a.append(ord(input("Please enter a letter ")))
for i in range (0,len(a)):
if(65<=a[i]<=65+26): #65=A
print(chr(a[i]-65+97))
#65=A, 97=a
elif(97<=a[i]<=97+26): #65=A
print(chr(a[i]+65-97))
else:
print("Error. Please enter only characters.")
Please enter a letter a
Please enter a letter B
Please enter a letter c
Please enter a letter D
A
b
C
d
if-else
statements.For those who have not yet made account in Dev.to, you can have a free easy sign-up using your mail or GitHub accounts. I would suggest the budding developers to create your GitHub free account right away. You would require to register sooner or later anyways