Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

String Concept in Python:-

The string is a collection of char, it will arrange multiple char using sequence. The string char index will be to start from 0 to length-1.

The string will be declared using  ' '" "  and  """


a= 'welcome'   #single line string
a= "welcome" #single line
a= """ welcome in scs """   #multiple line with proper syntax format

    


WAP to count total vowel and consonant in String?

s= 'welcome'    #['w','e','l','c','o','m','e']
c=0
d=0
for i in range(0,len(s)):
    if s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u':
        c=c+1
    else:
        d=d+1

print("vowel",c,"consonant",d)     


......................................................................
MOST OF THE STRING PROGRAM WILL BE RELATED WITH ASCII CODE HENCE PYTHON PROVIDE TWO DIFFERENT METHOD TO PERFORM OPERATION FROM
ASCII TO CHAR AND CHAR TO ASCII

print(ord('a'))  #97   #char to ascii
print(chr(65))   #A    #ascii to char


WAP to find max char in String?

s= 'ramesh'
m = s[0]
for i in range(1,len(s)):
   if m<s[i]:   #s<h
       m=s[i]
print(m) 


ASSIGNMENT:-

1)WAP to reverse string where vowel will be in the same position?

for example  Ramesh          hasemr

Solution:-

s="ramesh"
s1="";
c = 5
for i in range(0,len(s)):
    if s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u':
        s1+=s[i]
    else:
        if s[c-i]=='a' or s[c-i]=='e' or s[c-i]=='i' or s[c-i]=='o' or s[c-i]=='u':
            s1+=s[i]
        else:
            s1=s1+s[c-i]
         

print(s1)   

2) WAP to check palindrome in String?

example  madam,Naman

Solution
s="madam"

c = len(s)-1
flag=True
for i in range(0,len(s)//2):
    if s[i]!=s[c-i]:
        flag=False
        break
 
if flag:
    print("pallindrom")
else:
    print("np")
     


3) WAP to convert a string from upper case to lower case and lower case to upper case?

Solution:-
s="MADAM"
s1=""

for i in range(0,len(s)):
   s1+=chr(ord(s[i])+32)
print(s1)

4) WAP to replace the string char from the next consecutive String char  (if char will be z then replace by a)?


   Manish  o.p  nbojti 


5) WAP to extract numeric, alphabets, and special char in separate string in any String?

6)  WAP to display a number of repeated char in String?

hello     h 1 e 1 l 2 o 1

Solution of this program:-

s = "mangalam"

for i in range(0,len(s)):
    c=0
    
    for k in range(0,i):
        if s[i]==s[k]:
            break
    else:    
     for j in range(i,len(s)):
        if s[i]==s[j]:
            c=c+1
     else:
        print(s[i],c)

7)  WAP to validate emaild?

8)  WAP to display a strength of password that password is weak, medium, and Strong according to predefined cases?

Strong (at least 3 special char, non-consecutive, not belonging with first name and Lastname, one upper case char and numeric is mandatory, length minimum 6)

Medium (at least 2 special char, non-consecutive, length minimum 6)







46 Comments

If you have any doubt in programming or join online classes then you can contact us by comment .

  1. Assignment1
    #wap to replace string to next consecutive string
    str=input("enter string")
    for i in range (0,len(str)):

    x=ord(str[i])
    if x>=65 and x<=90:
    x=x+1
    print(chr(x))
    else:
    x>=97 and x<=122
    x=x+1
    print(chr(x))

    ReplyDelete
  2. Assignment2
    #wap to convert a string from upper case to lower case and vice-versa
    string=input("enter string")
    for i in range(0,len(string)):
    s=ord(string[i])
    if s>=65 and s<=90:
    s=s+32
    s1=chr(s)
    print(s1,end='')

    else:

    s=s-32
    s1=chr(s)
    print(s1,end='')

    ReplyDelete
  3. Assignment 3-
    #WAP to extract numeric, alphabets, and special char in separate string in any String?
    str=input("enter any string")
    s1=''
    s2=''
    s3=''
    for i in range(0,len(str)):
    s=ord(str[i])
    if s>=48 and s<=57:
    s1=chr(s)
    print("enter string is numeric",s)
    elif(s>=65 and s<=90) or (s>=97 and s<=122):
    s2=chr(s)
    print("alphabet string",s)
    elif(s>=32 and s<=47) or (s>=58 and s<=64) or (s>=123 and s<=126):
    s3=chr(s)
    print("special charcter is",s3)

    ReplyDelete
  4. #predefine method of string
    1)capatlize()-Converts the first character to upper case
    implement-
    s1 = "hello, and hi"

    x = s1.capitalize()

    print (x)
    2)casefold()-Converts string into lower case
    implement-
    s2 = " Welcome To My World"

    x = s2.casefold()

    print(x)
    3)centre()-Returns a centered string
    implement-
    s3 = "banana"

    x = s3.center(20)

    print(x)
    4)count()-Returns the number of times a specified value occurs in a string
    implement-
    s4 = "I love mango,mango is yellow color "

    x = s4.count("mango")

    print(x)
    5)Upper()-Converts a string into upper case
    implement-
    s5 = "Hello my friends"

    x = s5.upper()

    print(x)
    6) translate()- method returns a string where some specified characters are replaced with the character described in a dictionary
    mydict = {65: 70};
    s6 = "Hello hi!";
    print(s6.translate(mydict));

    7)strip()-The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove)

    implement-
    s7 = " company "

    x = s7.strip()

    print("mnc", x, "TCS")
    8)isnumeric()- isnumeric() method returns True if all the characters are numeric (0-9), otherwise False.
    implement-
    s8 = "12345"

    x = s8.isnumeric()

    print(x)
    9) format()- method formats the specified value(s) and insert them inside the string's placeholder.
    example-
    Insert the price inside the placeholder, the price should be in fixed point, two-decimal format:

    implement-

    s9 = "For only {price:.2f} dollars!"
    print(s9.format(price = 49))
    10) islower()- method returns True if all the characters are in lower case, otherwise False.

    Numbers, symbols and spaces are not checked, only alphabet characters.
    Check if all the characters in the text are in lower case:

    s10 = "hello world!"

    x = s10.islower()

    print(x)







































    #predefine method of string
    1)capatlize()-Converts the first character to upper case
    implement-
    s1 = "hello, and hi"

    x = s1.capitalize()

    print (x)
    2)casefold()-Converts string into lower case
    implement-
    s2 = " Welcome To My World"

    x = s2.casefold()

    print(x)
    3)centre()-Returns a centered string
    implement-
    s3 = "banana"

    x = s3.center(20)

    print(x)
    4)count()-Returns the number of times a specified value occurs in a string
    implement-
    s4 = "I love mango,mango is yellow color "

    x = s4.count("mango")

    print(x)
    5)Upper()-Converts a string into upper case
    implement-
    s5 = "Hello my friends"

    x = s5.upper()

    print(x)
    6) translate()- method returns a string where some specified characters are replaced with the character described in a dictionary
    mydict = {65: 70};
    s6 = "Hello hi!";
    print(s6.translate(mydict));

    7)strip()-The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove)

    implement-
    s7 = " company "

    x = s7.strip()

    print("mnc", x, "TCS")
    8)isnumeric()- isnumeric() method returns True if all the characters are numeric (0-9), otherwise False.
    implement-
    s8 = "12345"

    x = s8.isnumeric()

    print(x)
    9) format()- method formats the specified value(s) and insert them inside the string's placeholder.
    example-
    Insert the price inside the placeholder, the price should be in fixed point, two-decimal format:

    implement-

    s9 = "For only {price:.2f} dollars!"
    print(s9.format(price = 49))
    10) islower()- method returns True if all the characters are in lower case, otherwise False.

    Numbers, symbols and spaces are not checked, only alphabet characters.
    Check if all the characters in the text are in lower case:

    s10 = "hello world!"

    x = s10.islower()

    print(x)







































    ReplyDelete
  5. Program to count vowels and consonant in a string-->>

    p="shiva concept solution"
    c=0
    v=0
    for i in range(0,len(p)):
    if p[i]=="a" or p[i]=="e" or p[i]=="i" or p[i]=="o" or p[i]=="u":
    v=v+1
    else:
    c=c+1
    print("total consonants=",c,"total vowels=",v)

    ReplyDelete
  6. Program to check palindrome in string-->>

    1st method-->>

    s="nama"
    c=len(s)-1
    flag=True
    for i in range(0,len(s)//2):
    if s[i]!=s[c-i]:
    flag=False
    break
    if flag:
    print("palindrome")
    else:
    print("not a palindrome")


    2nd method-->>
    x = "refer"
    w=""
    for i in x:
    w=i+w
    if (x==w):
    print ("it is a palindrome")
    else:
    print("it is not a palindrome")

    ReplyDelete
  7. Program to convert string from upper case to lower case and lower case to upper case-->>

    s="SUBSERVIENT"
    s1=""
    for i in range(0,len(s)):
    s1+=chr(ord(s[i])+32)
    print(s1)

    ReplyDelete
  8. # PYTHON( 6 To 7 PM BATCH)

    #CODE to Find Palindrome String

    a=input("Enter The String :\t")
    b=a[len(a)::-1]
    if a== b:
    print(" Palindrome String")
    else:
    print("Not a Palindrome String")

    ReplyDelete
  9. #To check pallindrome
    s = "poppop"
    c= len(s)-1
    flag=True

    for i in range(0, len(s)//2):
    if s[i]!=s[c-i]:
    flag = False
    if flag:
    print(s,"Is Pallindrome")
    else:
    print(s,"Is Not Pallindrome")

    ReplyDelete
  10. # Upper case_lower case
    s = "HELLO"
    c=''

    for i in range(0,len(s)):
    c+= chr(ord(s[i])+32)
    print(c)

    ReplyDelete
  11. # String in reverse form
    s= "parag"

    for i in range(0,len(s)):
    c=s[i]
    b= chr(97+(122-ord(c)))
    print(b,end='')

    ReplyDelete
  12. #WAP to replace the string char from the next consecutive String char (if char will be z then replace by a)?
    a = "zebra"

    for i in range(0,len(a)):
    if a[i]=="z":
    print("a",end='')
    else:
    b= chr(ord(a[i])+1)
    print(b,end='')

    ReplyDelete
  13. #WAP to extract numeric, alphabets, and special char in separate string in any String?
    x= "My name is Arun, arun@gmail.com, c.s branch, my percentage is 98%."
    num=''
    sc=''
    st=''

    for i in range(0,len(x)):
    if x[i]=="1" or x[i]=="2" or x[i]=="3" or x[i]=="4" or x[i]=="5" or x[i]=="6" or x[i]=="7" or x[i]=="8" or x[i]=="9" or x[i]=="0":
    num = num + str(x[i])

    if x[i]=="!" or x[i]=="@" or x[i]=="#" or x[i]=="$" or x[i]=="%" or x[i]=="^" or x[i]=="&" or x[i]=="*" or x[i]=="(" or x[i]==")" or x[i]=="." or x[i]==",":
    sc = sc+str(x[i])

    else:
    if x[i] not in(num or sc):
    st =st+ x[i]

    print(num)
    print(sc)
    print(st)

    ReplyDelete
  14. Program to display repeated char in String
    s = "welcomeo"
    count=[]
    for i in range(0,len(s)):

    c=1
    for j in range(i+1,len(s)):
    if s[i]==s[j] and s[i] not in count:
    c=c+1

    if s[i] not in count:
    count.append(s[i])
    print(s[i],c)



    print(count)

    ReplyDelete
  15. # Python( 6 To 7 PM BATCH)

    # CODE for Reverse String Where Vowel will be in the Same Position.

    s="ramesh"
    s1="";

    for i in range(len(s)-1,-1,-1):

    if s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u':
    s1+=s[i]
    else:
    s1=s1+s[i]

    print(s1)

    ReplyDelete


  16. # PYTHON ( 6 To 7 PM BATCH)
    # CODE to replace the string char from the next consecutive String char.

    s=str(input("Enter Any Name :-\t"))
    s1 = ''
    for i in s:

    if i=="Z":
    s1 = s1 +"A"
    else:

    s1 =s1+chr(ord(i)+1)

    print(s1.upper())

    ReplyDelete

  17. # PYTHON ( 6 To 7 Pm BATCH)
    # Program to Extract Numeric, Alphabets And Special Character from String.

    i = input("Please Enter Your Own Character : ")


    for ch in i:
    if((ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z')):
    print("The Given Character ", ch, "is an Alphabet")
    elif(ch >= '0' and ch <= '9'):
    print("The Given Character ", ch, "is a Digit")
    else:
    print("The Given Character ", ch, "is a Special Character")

    ReplyDelete

  18. # PYTHON ( 6 To 7 PM BATCH)
    # Program to Display a Number of Repeated Char in String.

    s = "ROHIT-KUMAR-PYTHON-CLASS"

    for i in s:

    a= s.count(i)

    if a==1:
    print(i,"--",a)
    a = 0

    if a>1:
    print(i,"--",a)
    s= s.replace(i,'')
    a = 0

    ReplyDelete
  19. #Akash patel
    #wap to replace string to next consecutive string:-
    str=input("enter string")
    for i in range (0,len(str)):

    x=ord(str[i])
    if x>=65 and x<=90:
    x=x+1
    print(chr(x))
    else:
    x>=97 and x<=122
    x=x+1
    print(chr(x))

    ReplyDelete
  20. #Akash patel
    #wap to convert a string from upper case to lower case and loer to uper
    string=input("enter string")
    for i in range(0,len(string)):
    s=ord(string[i])
    if s>=65 and s<=90:
    s=s+32
    s1=chr(s)
    print(s1,end='')
    else:
    s=s-32
    s1=chr(s)
    print(s1,end='')

    ReplyDelete
  21. #Akash patel
    #WAP to extract numeric, alphabets, and special char in separate string in any String?
    str=input("enter any string")
    s1=''
    s2=''
    s3=''
    for i in range(0,len(str)):
    s=ord(str[i])
    if s>=48 and s<=57:
    s1=chr(s)
    print("enter string is numeric",s1)
    elif(s>=65 and s<=90) or (s>=97 and s<=122):
    s2=chr(s)
    print("alphabet string",s2)
    elif(s>=32 and s<=47) or (s>=58 and s<=64) or (s>=123 and s<=126):
    s3=chr(s)
    print("special charcter is",s3)

    ReplyDelete
  22. -Ajay Upadhyay
    #Programm for convert lower case to upper and upper case to lower
    int = input("Enter your name :")
    for i in range(0,len(int)):
    s=ord(int[i])
    if s<=96:
    s = s + 32
    else:
    s = s - 32
    t=chr(s)
    print(t)

    ReplyDelete
  23. #Shivam Shukla
    #WAP to count total vowel and consonant in String?
    val= 'Welcome' #['w','e','l','c','o','m','e']
    vowel=consonant=0
    for i in val:
    k=ord(i);
    if((k>=65 and k<=90) or (k>=97 and k<=122)):
    if(k>=65 and k<=90):
    i=chr(k+32);
    if i=='a' or i=='e' or i=='i' or i=='o' or i=='u':
    vowel+=1;
    else:
    consonant+=1;
    print("vowel",vowel,"consonant",consonant);

    ReplyDelete
  24. #Shivam Shukla
    #WAP to find max char in String?
    val= 'ramesh';
    count=0;
    for i in val:
    count+=1;
    k=val[0];
    for i in range(1,count):
    if(k<val[i]):
    k=val[i];
    print("Max char is : ",k);

    ReplyDelete
  25. #Shivam Shukla
    #2.1) WAP to check palindrome in String?
    #Example : madam(Correct), Madam(Incorrect)
    val="madam";
    count=0
    for i in val:
    count+=1;
    for i in range(0,count//2):
    if(val[i]!=val[count-1-i]):
    print("It's not a palindrome...");
    break;
    else:
    print("It's a palindrome...")

    ReplyDelete
  26. #2.2) WAP to check palindrome in String?
    #Example : madam(Correct), mAdam(Correct)
    val="mAdam";
    count=0
    for i in val:
    count+=1;
    for i in range(0,count//2):
    k=val[i]
    if(ord(k)>=65 and ord(k)<=90):
    k=chr(ord(k)+32);
    if(k!=val[count-1-i]):
    print("It's not a palindrome...");
    break;
    else:
    print("It's a palindrome...")

    ReplyDelete
  27. #Shivam Shukla
    #3.1) WAP to convert a string from upper case to lower case --or-- all's lower case...??
    val1="ShriVashu1"
    val2=''
    for i in val1:
    k=ord(i)
    val2 = val2+chr(k+32) if(k>=65 and k<=90) else val2+i
    print(val2)

    ReplyDelete
  28. #3.2) WAP to convert a string from lower case to upper case --or-- all's upper case...??
    val1="ShriVashu1"
    val2=''
    for i in val1:
    k=ord(i)
    val2 = val2+chr(k-32) if(k>=97 and k<=122) else val2+i
    print(val2)

    ReplyDelete
  29. #Shivam Shukla
    #3.2) WAP to convert a string from lower case to upper case --or-- all's upper case...??
    val1="ShriVashu1"
    val2=''
    for i in val1:
    k=ord(i)
    val2 = val2+chr(k-32) if(k>=97 and k<=122) else val2+i
    print(val2)

    ReplyDelete
  30. #Shivam Shukla
    #3.3) WAP to convert a string from all charactor's if upper case then lower case and if in lower case then upper case...??
    val1="ShriVashu1"
    val2=''
    for i in val1:
    k=ord(i)
    if(k>=65 and k<=90):
    val2+=chr(k+32)
    elif(k>=97 and k<=122):
    val2+=chr(k-32)
    else:
    val2+=i
    print(val2)

    ReplyDelete
  31. #Shivam Shukla
    #4.1) WAP to replace the string char from the next consecutive String char (if char will be z then replace by a)?
    #Examples : ShriVashu > tisjwbtiv | ShriVashu1 > tisjwbtiv1
    val1='ShriVashu1'
    val2=''
    for i in val1:
    k=ord(i);
    if((k>=65 and k<=90) or (k>=97 and k<=122)):
    if(k>=65 and k<=90):
    if(k==90):
    k=65;
    k=k+32;
    val2+=chr(k+1);
    else:
    val2+=chr(k);
    print(val2);

    ReplyDelete
  32. #Shivam Shukla
    #4.2) WAP to replace the string char from the next consecutive String char (if char will be z then replace by a)?
    #Examples : ShriVashu > TisjWbtiv | ShriVashu1 > TisjWbtiv1
    val1='ShriVashu1'
    val2=''
    for i in val1:
    k=ord(i)
    if(k>=65 and k<=90):
    if(k==90):
    k=65;
    val2+=chr(k+1)
    elif(k>=97 and k<=122):
    if(k==122):
    k=97;
    val2+=chr(k+1)
    else:
    val2+=chr(k)
    print(val2)

    ReplyDelete
  33. #Shivam Shukla
    #5) WAP to extract numeric, alphabets, and special char in separate string in any String?
    val='$ShriVashu#3108@'
    num='';
    alpha='';
    spchr='';
    for i in val:
    k=ord(i)
    if(k>=48 and k<=57):
    num+=i;
    continue;
    elif((k>=65 and k<=90) or (k>=97 and k<=122)):
    alpha+=i;
    continue;
    else:
    spchr+=i;
    print("numbers :",num,"\nalphabets :",alpha,"\n special charactor's :",spchr)

    ReplyDelete
  34. #Shivam Shukla
    #6) WAP to display a number of repeated char in String?
    #hello >> h-1 e-1 l-2 o-1
    val1='hello';
    val2='';
    for i in range(0,len(val1)):
    s=0;
    for j in val2:
    if(val1[i]==j):
    s=1;
    break;
    if(s==1):
    continue;
    s=0;
    for j in range(i,len(val1)):
    if(val1[i]==val1[j]):
    s+=1;
    print(val1[i],"-",s);
    val2+=val1[i]

    ReplyDelete
  35. #Shivam Shukla
    #7) WAP to validate emaild?
    Valid="@gmail.com";
    Email=input("Enter Email Id : ");
    v=len(Valid);
    e=len(Email);
    if(e>v):
    for i in range(0,v):
    if(Valid[i]!=Email[(e-v)+i]):
    print("Invalid Email");
    break;
    else:
    print("Valid Email")
    else:
    print("Invalid Email")

    ReplyDelete
  36. #Abhishek Singh
    #1)WAP to reverse string where vowel will be in the same position?
    s=input("Enter any Name:::")
    s1=""
    vowel="aeiouAEIOU"
    lnt=len(s)
    i=lnt

    for j in range(0,lnt):
    if(s[j] in vowel):
    s1=s1+s[j]
    else:
    while i>0:
    i-=1
    if (s[i] in vowel)==False:
    break
    s1=s1+s[i]
    print(s1)

    ReplyDelete
  37. # Ankit Saxena
    # count total vowel and consonant in String
    a=input("Enter your name:")
    vowel=0
    cons=0
    for i in range(0,len(a)):
    if(a[i]!=" "):
    if(a[i]=="a" or a[i]=="i" or a[i]=="o"or a[i]=="u"
    or a[i]=="A" or a[i]=="E" or a[i]=="O" or a[i]=="U"):
    vowel=vowel+1

    else:
    cons=cons+1
    print("Total Vowels=",vowel)
    print("Total Consonents=",cons)

    ReplyDelete
  38. #Shivam Shukla
    #1)WAP to reverse string where vowel will be in the same position?
    #for example - ramesh > hasemr
    val="shrivashu";
    list1=''
    list2=''
    for i in range(len(val)-1,-1,-1):
    k=val[i];
    if(not(k=='a' or k=='e' or k=='i' or k=='o' or k=='u')):
    list1+=val[i]
    s=0
    for i in range(0,len(val)):
    j=val[i]
    if(j=='a' or j=='e' or j=='i' or j=='o' or j=='u'):
    list2+=j;
    else:
    list2+=list1[s]
    s+=1
    print(list2)

    ReplyDelete
  39. #Shivam Shukla
    #8) WAP to display a strength of password that password is weak, medium, and Strong according to predefined cases?
    #Strong (at least 3 special char, one upper case char and numeric is mandatory, length minimum 6)
    #Medium (at least 2 special char, length minimum 6)

    '''fName='Shivam'; #input("Enter First Name : ");
    lName='Shukla'; #input("Enter Last Name : ");
    User='ShriVashu'; #input("Enter User Id : ");'''

    PassWord=input("Enter your Password : ");
    Medium=Strong=0
    spChar=toCase=upCase=Num=nonCon=0
    for i in range(0,len(PassWord)):
    k=ord(PassWord[i]);
    if(k>=48 and k<=57):
    Num+=1;
    elif((k>=65 and k<=90) or (k>=97 and k<=122)):
    if(k>=65 and k<=90):
    upCase=1;
    toCase+=1;
    else:
    spChar+=1;
    if(len(PassWord)>=6 and spChar>=3 and upCase==1 and Num>0):
    print("High Password")
    elif(len(PassWord)>=6 and spChar>=2):
    print("Medium Password!")
    else:
    print("Week Password!")

    ReplyDelete
  40. #Abhishek Singh
    #6) WAP to display a number of repeated char in String?
    s="mangalam"
    s1=""

    for i in range(0,len(s)):
    if (s[i] in s1)==False:
    s1=s1+s[i]

    for j in range(0,len(s1)):
    count=0
    for k in range(0,len(s)):
    if(s1[j]==s[k]):
    count+=1
    print(s1[j],":repeated ",count," times")

    ReplyDelete
  41. #Abhishek Kumar
    #3) WAP to convert a string from upper case to lower case and lower case to upper case?
    #Program takes user choice to convert all characters of String to either UPPER CASE or LOWER CASE except special characters
    s=input("Enter a word:::")
    s1=""
    d=ord('a')-ord('A')
    ch=input("Enter user choice for upper/lower:::(u/l):::")

    for i in range(0,len(s)):

    if ch=='l':
    if ord(s[i])>=ord('A') and ord(s[i])<=ord('Z'):
    s1=s1+chr(ord(s[i])+d)
    else:
    s1=s1+s[i]

    elif ch=='u':
    if ord(s[i])>=ord('a') and ord(s[i])<=ord('z'):
    s1=s1+chr(ord(s[i])-d)
    else:
    s1=s1+s[i]
    else:
    s1=s1+s[i]

    print(s1)

    ReplyDelete
  42. #Shivam Shukla
    #7.1) WAP to validate emaild?
    #Note : if we have only '@gmail.com' in last.....
    Valid="@gmail.com";
    Email=input("Enter Email Id : ");
    v=len(Valid);
    e=len(Email);
    if(e>v):
    for i in range(0,v):
    if(Valid[i]!=Email[(e-v)+i]):
    print("Invalid Email");
    break;
    else:
    print("Valid Email")
    else:
    print("Invalid Email")

    ReplyDelete
  43. #Shivam Shukla
    #7.2) WAP to validate emaild?
    Email=input("Enter Email Id : ");
    e=len(Email);
    fP=sP=tP=Exit=0;
    for i in range(0,e):
    k=Email[i];
    if(fP>0 or k!='@'):
    fP+=1;
    if(sP>0 or k=='@'):
    if(sP>0 and k=='@'):
    Exit=1;
    break;
    sP+=1;
    if(sP>1 and tP>0 or k=='.'):
    tP+=1;
    print("Exit :", "Applied" if(Exit==1) else "Not Applied" ," | before '@' :",fP-sP," | between '@' and '.' :",sP-1-tP," | after '.' :",tP-1);
    if(Exit==0 and fP-sP>0 and sP-tP-1>0 and tP-1>0):
    print(">> your Mail Id is Valid.....")
    else:
    print(">> your Mail Id is Invalid.....")

    ReplyDelete
  44. #8.2) WAP to display a strength of password that password is weak, medium, and Strong according to predefined cases?
    #Strong (at least 3 special char, non-consecutive, not belonging with first name and Lastname, one upper case char and numeric is mandatory, length minimum 6)
    #Medium (at least 2 special char, non-consecutive, length minimum 6)

    fName='shivam'; #input("Enter First Name : ");
    lName='shukla'; #input("Enter Last Name : ");
    User='ShriVashu07'; #input("Enter User Id : ");

    PassWord=input("Enter your Password : ");
    Medium=Strong=0
    spChar=toCase=upCase=Num=nonCon=0
    for i in range(0,len(PassWord)):
    k=ord(PassWord[i]);
    if(k>=48 and k<=57):
    Num+=1;
    elif((k>=65 and k<=90) or (k>=97 and k<=122)):
    if(k>=65 and k<=90):
    upCase=1;
    toCase+=1;
    else:
    spChar+=1;

    fVal=lVal=fExit=lExit=0
    for i in range(0,len(PassWord) - (len(fName) if(len(lName)>len(fName)) else len(lName))+1):
    if(fExit==0):
    for j in range(0,len(fName)):
    if(PassWord[i+j]==fName[j]):
    fVal+=1;
    if(fVal==len(fName)):
    print("First Name Matched!");
    fExit=1;
    if(lExit==0):
    for j in range(0,len(lName)):
    if(PassWord[i+j]==lName[j]):
    lVal+=1;
    if(lVal==len(lName)):
    print("Second Name Matched!");
    lExit=1;


    if(fExit==0 and lExit==0 and len(PassWord)>=6 and spChar>=3 and upCase==1 and Num>0):
    print("High Password")
    elif(fExit==0 and lExit==0 and len(PassWord)>=6 and spChar>=2):
    print("Medium Password!")
    else:
    print("Week Password!")

    ReplyDelete
  45. #Shivam Shukla
    #4.1) WAP to replace the string char from the next consecutive String char (if char will be z then replace by a)?
    #Examples : ShriVashu > tisjwbtiv | ShriVashu1 > tisjwbtiv1
    val1='aAzZ1'
    val2=''
    for i in val1:
    k=ord(i);
    if((k>=65 and k<=90) or (k>=97 and k<=122)):
    if(k>=65 and k<=90):
    k=k+32;
    val2 = val2+'a' if(k==122) else val2+chr(k+1)
    else:
    val2+=chr(k);
    print(val2);

    ReplyDelete
  46. #Shivam Shukla
    #4.2) WAP to replace the string char from the next consecutive String char (if char will be z then replace by a)?
    #Examples : ShriVashu > TisjWbtiv | ShriVashu1 > TisjWbtiv1
    val1='ShriVashu1'
    val2=''
    for i in val1:
    k=ord(i)
    if(k>=65 and k<=90):
    val2 = val2+'A' if(k==90) else val2+chr(k+1)
    elif(k>=97 and k<=122):
    val2 = val2+'a' if(k==122) else val2+chr(k+1)
    else:
    val2+=chr(k)
    print(val2)

    ReplyDelete

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post