Question

In python, Write short programs (notebook cells) showing how to create & use the following data...

In python, Write short programs (notebook cells) showing how to create & use the following data types:

  • Tuples
  • Ints
  • Floats
  • Dictionaries
  • Sets
  • Numpy array

The programming details are provided in a separate Jupyter notebook file

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#tuple example

tup=("Tuple","Example")
print(type(tup))

#printing the tuple  one by one
for t in tup:
    print(t)
#int

int_ex=int("124")

print("Type is: ",type(int_ex))
print("Int value is",int_ex)

#Float

float_ex=float("124.02")

print("Type is: ",type(float_ex))

print("Float value is",float_ex)

# Dictionary example

dic={'Name':'MyName','age':22,'Gender':'M'}
# printing Dictionary from key
print(dic['Name'])

print("Type is: ",type(dic))
#printing the Dictionary one by one
for key in dic:
    print("{key} =>{value}".format(key=key,value=dic[key]))

# Set example

set_ex={2,45,32,2,54,67}

print("Type is: ",type(set_ex))

for s in set_ex:
    print(s)


#import statement for numpy
from numpy import *

#intializing the array using numpy
arr= array([1,2,3,4,5,7])

#printing the array one by one
for i in arr:
    print(i)
#printing whole array
print(arr)
Add a comment
Know the answer?
Add Answer to:
In python, Write short programs (notebook cells) showing how to create & use the following data...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Questions 1. How to create a comment in python? 2. The way to obtain user input...

    Questions 1. How to create a comment in python? 2. The way to obtain user input from command line 3. List standard mathematical operators in python and explain them 4. List comparison operators in python 5. Explain while loop. Give example 6. Explain for loop. Give example 7. How to create infinite loop? And how to stop it? 8. Explain a built-in function ‘range’ for ‘for’ loop 9. Explain break statement 10. Explain continue statement 11. Explain pass statement 12....

  • For each problem, you must: Write a Python program Test, debug, and execute the Python program...

    For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...

  • Please use python Programming Language: Select one of the following topics: Band Character Account Create a...

    Please use python Programming Language: Select one of the following topics: Band Character Account Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method. Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the...

  • The following are short Python calculations. Give the answer and the Python code for each. 1....

    The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...

  • Use the link in the Jupyter Notebook activity to access your Python script. Once you have...

    Use the link in the Jupyter Notebook activity to access your Python script. Once you have made your calculations, complete this discussion. The script will output answers to the questions given below. You must attach your Python script output as an HTML file and respond to the questions below. In this discussion, you will apply the statistical concepts and techniques covered in this week's reading about hypothesis testing for the difference between two population proportions. In the previous week’s discussion,...

  • Please write comments with the program. Python programming!! Part III - write student data In this...

    Please write comments with the program. Python programming!! Part III - write student data In this part the program should create a .csv file and fill it with generated student information. The program should: Ask the user for a name for the .csv file (use your own name for the exercise) Create the .csv file with columns named - ID, first-name, GPA Based on the information received in part I, generate and fill students information in the CSV file Tell...

  • Learn how to use the advanced data structures (such as: list, tuple, string, dictionary, and set)...

    Learn how to use the advanced data structures (such as: list, tuple, string, dictionary, and set) ·         Learn and practice how to use functions. ·         Learn and practice how to use file I/Os. ·         Appreciate the importance of data validations. ·         Provide appropriate documentation and good programming style. Python Programming Description of the problem: Write a “censor” program that first reads a file with “bad words” such as “sex”, “drug”, “rape”, “kill”, and so on, places them in a set, and then reads an...

  • Python Problem: Variance Explanation: Problem 1: Computing variance For this problem, you will write a function...

    Python Problem: Variance Explanation: Problem 1: Computing variance For this problem, you will write a function variance that takes a list whose elements are numbers (floats or ints), and returns their variance, a single number. (If you don't remember how to compute variance, check the lecture notebook; it's one of the intermediate steps in computing standard deviation.) You should not use NumPy or any other Python libraries for this problem. For now, worry only about correctness, not efficiency. Passing an...

  • DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a...

    DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a function called inch2cm that takes one number in inches as a parameter, converts it to the centimeters and prints the result. The program output is shown below. Input: 14 Output: 14 inches = 35.56 centimeter Write a program and create the following functions: shapes(): takes the shape name and a number as parameters, and calls the proper function to calculate the area. areaCircle(): take...

  • See notes in Lab4T1SHYPI.java Use the program Lab4T1SHYPL.java to answer the following questions. Part 1: Create...

    See notes in Lab4T1SHYPI.java Use the program Lab4T1SHYPL.java to answer the following questions. Part 1: Create a new program XYZ1234Lab4T1Part1.java and copy the body from Lab4T1SHYPIjava into the new program. In this new program, make the (29 points total a 1.a) Replace the sets of variables with arrays for each kind of data. Ex. shPubl, shPub2, shPub3, and shPub4 should be replaced with a single array StringIl shPub. Replace the variables for superHeros, shYear, shIssue, and shMovi Arrays should hold...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT