DATA STRUCTURE EXCERCISE 1. Write a python script that ...
DATA STRUCTURE EXCERCISE
1. Write a python script that accepts an integer n as user input (with empty prompt) Create a list of integers from 0 to n-1 Print this list
Solution
n=int(input()) L=list(range(n)) print(L)
2. Write a python script that accepts an integer n as user input (with empty prompt) Store the square of all the odd numbers less than n in a list Print this list
Example:
Input: 7
Output: [1, 9, 25]
Solution
n=int(input()) L=[] for i in range(n): if(i%2!=0):
L.append(i*i) print(L)
3. Write a python script that accepts an integer n as user input (with empty prompt) Store the square of all the odd numbers less than n in a tuple Print that tuple
Example:
Input: 7
Output: (1, 9, 25)
Solution
n=int(input()) T=() for i in range(n): if(i%2!=0):
T=T +(i*i,) print(T)
4. Write a python script that accepts an integer, n (>= 1) from the user. Store the first n numbers of the Fibonnaci series in a list. Print this list. Example:
Input: 5
Output: [0, 1, 1, 2, 3]
Solution
n=int(input()) a=0 b=1 c=a+b L=[a,b,c] i=3 while(i ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- big endian and little endian formats for integers
- read map and extract modis aerosol data using python scripts
- destring — convert string variables to numeric variables
- data structure excercise 1 write a python script that
- data 301 introduction to data analytics python
- flatten 2d matrix
- working with dates and times stata
- taking inputs scanf
- a guide to f string formatting in python
Related searches
- data structure diagram
- run a python script cmd
- how to write a data analysis paper
- 1 prepare a business plan proposal for a seminar or training program that could
- write a program that lets user enter in a potentially unlimited series of price
- data structure using java
- write a python library
- run python script in python shell
- python write a variable into a file
- python script to open a file
- python write a binary file
- call python script from another python script