For each of the below features you should do the following: 1. Write a short pro
ID: 3831087 • Letter: F
Question
For each of the below features you should do the following:
1. Write a short program or programs to investigate its use. You may combine more than one feature into a single program.
2. Explain how the feature works in Python and compare it to one or more languages with which you are familiar.
3. Critique the implementation or use of the feature or construct.
Note: Some of the features above are not included in Python, in which case you should note that they are missing and critique the decision to leave them out.
1. interpretation
2. Boolean expressions
3. short circuit evaluation
4. numeric types
5. strings
6. arrays
7. lists
8. tuples
9. slices
10. index range checking
11. dictionaries
12. if statement
13. switch statement
14. for loop
15. while loop
16. indentation to denote code blocks
17. type binding
18. type checking
19. functions
Any help is appreciated with this one. Thanks.
Explanation / Answer
1)Interpreted : This is easy to understand-> A high level language run and executed by an Interpreter(a program which converts the high-level language to machine code and then executing) on the go; It processes the program a little at a time
2)Boolean and If statement:
Python boolean operators are spelled out as the words "and" "or" "not", instead of the && syntax in other languages.
lets see an example
lets understand by example:
4) Numeric types:
Python supports 4 types->
int,long,float,complex
5)Strings in python:
OUTPUT:
6) Arrays: Simple way to declare and initialize an array.
7)Lists:
8) Tuples:
OUTPUT:
9) Slices:
>>> a = [1, 2, 3, 4, 5, 6, 7, 8]
>>> a[1:4]
[2, 3, 4]
11)dictionaries:
Output:
13. switch statement:
There is no switch keyword or statement in python we can replicate the switch working with if - else ladder:
14. for loop:
OUTPUT;
15. while loop:
Output;
16. indentation to denote code blocks: Understand the indentation in this while loop.
18. type checking: This is used to check the type of the variable:
19. functions: this is a simple example of funtion in python:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.