Assignment
Assignment
Assignment:1
Q1. What is compiler? Why should we study Compiler; Give at least 5 suitable
reasons
A compiler is a program that converts statements written in a programming language into
machine language, or "code," that is used by a computer's processor. A programmer often
uses an editor to write language statements in a language such as Pascal or C one line at a
time. The source statements are contained in the file that is created. The programmer then
launches the appropriate language compiler, giving the name of the source statement file.
It is useful for a computer scientist to study compiler design for several reasons.
1. Anyone who does any software development needs to use a compiler. It is a good
idea to understand what is going on inside the tools that you use.
2. Compilers are sophisticated text processors. Most programs need to do some text
processing, even if only to read in the contents of a configuration file.
Q2. Design Regular Expression for password that must hold the following conditions and
then write code.
INPUT:
import re
pattern = r"^[?_][?_][C][A-z+0-9][A-z+0-9][d][d][A-z+0-9][A-z+0-9][z][0-9][0-9]$"
password = input("Enter string to test: ")
result = re.findall(pattern, password)
if (result):
print ("Valid password")
else:
print ("Password not valid")
• Password should be 11 characters in length
1
MUHAMMAD MUKARRAM (02-134192-054)