You are on page 1of 20

REPORT ON: …I…T…W…o…r…ks…h…o…p …La..

…b …(P…y…th…o…n…) …(P…C…
C…-C…S…3…93…) ............................................................................. Lab.

NAME: SHUBHAM MAITY

DEPARTMENT: …C…O…M…P…U…T…E…R…S…C…I…E…N…CE……&…E…N…G…
I…N…E…ER…I…N…G………………………..

ROLL NO: .2…0…/…C…S…E/..…058 SEM: ……3.…rd….… GRP: …C.…… SECTION:


…C…S.E..-..I.I....

ASSIGNMENT NO: ……V…I.I.……PROGRAM NO: …1.,.2…,…3,…4…,5…,6…,…


7…,8…,9………………....

TITLE / OBJECTIVE:

1.COUNT VOWELS
2.COUNT UPPERCASE,LOWERCASE,DIGIT,WHITESPACES
3.SWAPPING
4.REVERSE
5.SHIFTING
6.INITIALS
7.PALINDROME
8.SHIFT REPEATEDLY
9.PASSWORD
PERFORMANCE DATE: …13.../.…1…2/…2…0…2…1.. SUBMISSION DATE: …2…
1/…1…2…/…2…0.2..1....

EXAMINER’S SIGNATURE: ……………………………………………………………………………..


IT Workshop Lab (Python)
(PCC-CS393)
CSE – 3rd Sem. – 2nd Year

1. Write a program that accepts a string from user. Your program should count and
display number of vowels in that string..

Program Name: vowels.py

print("\t******COUNT VOWELS******\n")
s=input("Enter the string: ")
i=0
v=0
for i in s:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or
i=='I' or i=='O' or i=='U'):
v+=1
print("Number of Vowels in {0} are: {1}".format(s,v))

Assignment No. – VII Page - 2 SHUBHAM MAITY, 20/CSE/058, </> CSE Dept, FIEM
OUTPUT

******COUNT VOWELS******

Enter the string: FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT


Number of Vowels in FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT are: 18
IT Workshop Lab (Python)
(PCC-CS393)
CSE – 3rd Sem. – 2nd Year

2. Write a program that reads a string from keyboard and display:


* The number of uppercase letters in the string
* The number of lowercase letters in the string
* The number of digits in the string
* The number of whitespace characters in the string.

Program Name: count.py

print("\t******COUNT******\n")
text=input('Enter a string: ')
lower=upper=digit=space=0

for ch in text:
if ch.isupper():
upper+=1
elif ch.islower():
lower+=1
elif ch.isdigit():
digit+=1
elif ch==' ':
space+=1

print('The number of uppercase letters:',upper)


print('The number of lowercase letters:',lower)
print('The number of digits:',digit)
print('The number of whitespace characters:',space)

OUTPUT

Assignment No. – VII Page - 4 DEBOJYOTI SAHA, 20/CSE/016, </> CSE Dept, FIEM
IT Workshop Lab (Python)
(PCC-CS393)
CSE – 3rd Sem. – 2nd Year

OUTPUT

******COUNT******

Enter a string: Shubham@1234


The number of uppercase letters: 1
The number of lowercase letters: 6
The number of digits: 4
The number of whitespace characters: 0

Assignment No. – VII Page - 5 SHUBHAM MAITY, 20/CSE/058, </> CSE Dept, FIEM
3. Write a Python program that accepts a string from user. Your program should
create and display a new string where the first and last characters have been
exchanged.

Program Name: SWAPPING.py

print("\t*****SWAPPING******\n")
s=input("ENTER THE STRING: ")
start=s[0]
end=s[-1]
swapstr=end+s[1:-1]+start
print(swapstr)
OUTPUT

*****SWAPPING******

ENTER THE STRING: SHUBHAM


MHUBHAS
4. Write a Python program that accepts a string from user. Your program should
create a new string in reverse of first string and display it.

Program Name: reverse.py

print("\t******STRING REVERSE******\n")
s=input("Enter the string: ")
rev=s[::-1]
print('REVERSE STRING: ',rev)
OUTPUT

******STRING REVERSE******

Enter the string: CRICKET


REVERSE STRING: TEKCIRC
5. Write a Python program that accepts a string from user. Your program should
create a new string by shifting one position to left.

Program Name: SWAP.py

print("\t******SWAPING******\n")
text=input('Enter a string: ')
newtext=text[1:]+text[0]
print('New string:',newtext)
OUTPUT

******SWAPING******

Enter a string: HELLO


New string: ELLOH
6. Write a program that asks the user to input his name and print its initials. Assuming
that the user always types first name, middle name and last name and does not
include any unnecessary spaces.

Program Name: initials.py

def printInitials(name):
if(len(name) == 0):
return
print(name[0].upper(),end=".")
for i in range(1, len(name) - 1):
if (name[i] == ' '):
print (name[i + 1].upper(),end=".")
print("\t******INITIALS******\n")
name = input("Enter the name: ")
printInitials(name)
OUTPUT

******INITIALS******

Enter the name: FUTURE INSTITUTE OF ENGINEERING AND MANAGEMENT


F.I.O.E.A.M.
7. A palindrome is a string that reads the same backward as forward. For example, the
words dad, madam and radar are all palindromes. Write a program that determines
whether the string is a palindrome.

Program Name: palindrome.py

print("\t******PALINDROME******\n")
text = input('Enter a string: ')
newtext = text[::-1]

if text == newtext:
print('String is palindrome')
else:
print('String is not palindrome')
OUTPUT

******PALINDROME******

Enter a string: MALAYALAM


String is palindrome
>>>
= RESTART: C:/Users/Shubham
Maity/AppData/Local/Programs/Python/Python39/pyt16.py
******PALINDROME******

Enter a string: INDIA


String is not palindrome
8. Write a program that display following output:
SHIFT
HIFTS
IFTSH
FTSHI
TSHIF
SHIFT

Program Name: shifting.py

print("\t******SHIFTING REPEATEDLY******\n")
text = input("Enter the string: ")
for i in range(0,6):
newtext = text[i:] + text[:i]
print(newtext)

OUTPUT:

******SHIFTING REPEATEDLY******

Enter the string: SHIFT


SHIFT
HIFTS
IFTSH
FTSHI
TSHIF
SHIFT
IT Workshop Lab (Python)
(PCC-CS393)
CSE – 3rd Sem. – 2nd Year

9. Write a program in python that accepts a string to setup a password. Your entered
password must meet the following requirements:
● The password must be at least eight characters long.
● It must contain at least one uppercase letter.
● It must contain at least one lowercase letter.
● It must contain at least one numeric digit.
Your program should perform this validation.

Program Name: password.py

print("\t******PASSWORD******\n")
length = lower = upper = digit = False
print("Conditions for valid password:\n● The password must be at least
eight characters long.\n● It must contain at least one uppercase
letter.\n● It must contain at least one lowercase letter.\n● It must contain
at least one numeric digit.\n")
password = input('Enter the password: ')
if len(password)>= 8:
length = True
for letter in password:
if letter.islower():
lower = True
elif letter.isupper():
upper = True
elif letter.isdigit():
digit = True
if length and lower and upper and digit:
print('That is a valid password.')
else:
print('That password is not valid.')

Assignment No. – VII Page - 18 DEBOJYOTI SAHA, 20/CSE/016, </> CSE Dept, FIEM
IT Workshop Lab (Python)
(PCC-CS393)
CSE – 3rd Sem. – 2nd Year

OUTPUT

******PASSWORD******

Conditions for valid password:


● The password must be at least eight characters long.
● It must contain at least one uppercase letter.
● It must contain at least one lowercase letter.
● It must contain at least one numeric digit.

Enter the password: Shubham@1234


That is a valid password.
>>>
= RESTART: C:/Users/Shubham Maity/AppData/Local/Programs/Python/Python39/pyt16.py
******PASSWORD******

Conditions for valid password:


● The password must be at least eight characters long.
● It must contain at least one uppercase letter.
● It must contain at least one lowercase letter.
● It must contain at least one numeric digit.

Enter the password: SHUBHAM2021


That password is not valid.

Assignment No. – VII Page - 19 SHUBHAM MAITY, 20/CSE/058, </> CSE Dept, FIEM

You might also like