Ch 3 Assignment soln
Ch 3 Assignment soln
2. What are the four steps for solving any given problem? Explain every
step in brief.
3. What is IDLE?
• IDLE stands for Integrated Development and Learning
Environment.
• It's the default Python development environment.
• Includes an interactive shell for running Python code line-by-line.
• Has a text editor with syntax highlighting for writing scripts.
• Offers a built-in debugger for troubleshooting code.
• Simple and beginner-friendly interface.
• Cross-platform: Works on Windows, macOS, and Linux.
• Best for learning and small projects, but less powerful than other
IDEs.
4. Briefly explain the salient features of Python.
1. Easy to Code
Python is a very high-level programming language, yet it is effortless to
learn. Anyone can learn to code in Python in just a few hours or a few
days.
2. Easy to Read
Python code looks like simple English words.
3. Free and Open-Source
Python is developed under an OSI-approved open-source license.
Hence, it is completely free to use, even for commercial purposes. It
doesn't cost anything to download Python or to include it in your
application.
4. Interpreted
When a programming language is interpreted, it means that the source
code is executed line by line, and not all at once.
5. Portable
Python is portable in the sense that the same code can be used on
different machines.
5. Write a pseudocode that will perform the following :
a) Read the marks of three subjects: Computer Science, Maths and
Physics out of 100.
b) Calculate the aggregate marks.
c) Calculate the percentage of marks.
6. What is interpreter? List the two ways to use the Python interpreter.
Interpreters are computer programs that will convert the source code
or a high-level language into intermediate code (machine-level
language). It is also called a translator in programming terminology.
Interpreters execute each line of statements slowly. This process is
called Interpretation. For example, Python is an interpreted language,
PHP, Ruby, and JavaScript.
There are two ways to use the Python interpreter:
a) Interactive mode
b) Script mode
Interactive mode allows the execution of individual statements
instantaneously. Whereas, Script mode allows us to write more than
one instruction in a file called Python source code file that can be
executed.
7. Write a code that prints your full name and your birthday as separate
strings in Python.
Name=”Patel Jiya”
Birthdate=”23-02-2009”
print(Name)
print(Birthdate)
8. Record what happens when the following statements are executed:
a) print(n=20) Error
b) print(10+7) 17
c) print(4.2,” Hello”,6-2,” world”,15/2.0) 4.2, Hello , 4 , world,7.5
d) print(“123abc”,sep=’-’) 123-abc
e) print(“XXX”,end=’!’) XXX!
10. Write a pseudocode to calculate and display the Area and perimeter
of a rectangle.
print(myvariable) # Output: 10
print(MyVariable) # Output: 20