Skip to content
Snippets Groups Projects
Commit 34186f32 authored by Rajesh's avatar Rajesh
Browse files

Exercises

parents
Branches
No related tags found
No related merge requests found
Showing
with 231 additions and 0 deletions
print("Hello World")
\ No newline at end of file
userName = input("Enter Your Name: ")
print(userName)
num1 = int(input("Enter First No: "))
num2 = int(input("Enter Second No:"))
print(num1+num2)
print("for loop: ")
for i in range(100):
if(i%2 == 0):
print(i)
print("while loop: ")
i = 0
while(i < 100):
if(i%2 == 0):
print(i)
i += 1
\ No newline at end of file
for i in range(50, 19, -1):
if(i%2 == 0):
print(i)
\ No newline at end of file
str=input("Enter a string")
print(len(str))
def maximum(str):
max = 0
maxi = 0
n=len(str)
for i in range(n):
if (str[i] == '('):
max+=1;
if(max>maxi):
maxi=max
elif (str[i] == ')'):
if(max > 0):
max-=1;
else:
return -1;
if(max !=0):
print("Not Valid")
return -1;
return maxi;
str=input("Enter a string")
print (maximum(str))
str1=input("Enter a string ")
dict = {}
for n in str1:
key = dict.keys()
if n in key:
dict[n] += 1
else:
dict[n] = 1
print (dict)
str=input("Enter a string ")
n=len(str)
if(n<2):
print("Empty String")
else:
print (str[0:2]+str[n-2:n])
str=input("Enter a string ")
x=str[0]
str=str.replace(x,'$')
print (x+str[1:])
s1=input("1")
s2=input("2")
s=s2[:2]+s1[2:]+" "+s1[:2]+s2[2:]
print(s)
def long(list):
max=0
for i in list:
if(len(i)>max):
max=len(i)
word = i
return word
list=["PHP", "Exercises", "Backend"]
print(long(list))
str=input("Enter a string ")
print ("In Uppercase " + str.upper())
print ("In lowercase " + str.lower())
def rev(str):
n=len(str)
if(n%4==0):
return (str[::-1])
str=input("Enter a string ")
print (rev(str))
s=input("Enter the string:")
s1=""
for i in s :
if(i.isupper()):
c=ord(i)
s1=s1+chr((c-3-65)%26+65)
else:
c=ord(i)
s1=s1+chr((c-3-97)%26+97)
print (s1)
path = '/home/cse3c/Downloads/sw.txt'
file = open(path,'r')
dict = {}
for x in file.readlines():
if x in dict:
dict[x]+=1
else:
dict[x]=1
print (dict)
file.close()
path = '/home/cse3c/Downloads/sun.txt'
file = open(path,'r')
dict = {}
for x in file.read().split():
x=x[3:]
x=x[:x.find('/')]
if x in dict:
dict[x]+=1
else:
dict[x]=1
for a,b in dict.items():
print(a,b)
file.close()
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Darth
Luke
Darth
Lea
Darth
Lea
Lea
Luke
Darth
Lea
Darth
Darth
Lea
Lea
Darth
Lea
Darth
Lea
Luke
Darth
Lea
Lea
Darth
Lea
Darth
Darth
Lea
Lea
Luke
Luke
Lea
Darth
Darth
Luke
Lea
Darth
Darth
Lea
Lea
Lea
Lea
Lea
Luke
Darth
Luke
Lea
Lea
Lea
Lea
Luke
Lea
Darth
Lea
Lea
Darth
Lea
Lea
Darth
Darth
Lea
Darth
Lea
Darth
Luke
Lea
Luke
Darth
Darth
Luke
Darth
Lea
Darth
Lea
Luke
Lea
Lea
Lea
Lea
Lea
Darth
Lea
Lea
Lea
Lea
Lea
Lea
Lea
Luke
Lea
Lea
Lea
Lea
Lea
Lea
Darth
Luke
Darth
Lea
Lea
Darth
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment