Question

Create a Python list (use first three letters of your name followed by the letter L...

  1. Create a Python list (use first three letters of your name followed by the letter L as the name of the list.) with the following data: 10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, ‘python’.
  1. Display the entire list with an appropriate message.
  2. Display the 4th element in the list with an appropriate message.
  3. Display the first 3 values of the list only.
  4. Display all the values starting from the sixth element to the end of the list.
  5. Change the value of the last element to ‘unix’ and display its changed value.
  1. Create a Python tuple (use first three letters of your name followed by the letter T as the name of the tuple.) with the following data: 115, ‘C#’, 345.
  1. Display the entire tuple with an appropriate message.
  2. Display the second element of the tuple with an appropriate message.
  3. Try to change the value of the first element to any other value and screenshot the output. Explain what has happened.
  1. Create a Python set (use first three letters of your name followed by the letter S as the name of the set.) with the following data: 1, 2, 3, 3, 4, 4, 5.
  1. Display the entire set.
  2. Try to display the second element of the set and screenshot the output. Explain what has happened.
  1. Create a Python dictionary (use first three letters of your name followed by the letter D as the name of the dictionary.)   with the following key/value pairs: 1: ‘syed’ , ‘key’:500.
  1. Print the entire dictionary.
  2. Verify the data type of the collection you just created.
  3. Print the value of the key 1.
  4. Print the value of the key ‘key’.
  5. Try to print the value of the key “john’ and screenshot the output. Explain what has happened.
  1. Develop an application in Python that does the following:
  • When you run the program it displays an appropriate welcome message.
  • It then prompts for any value of temperature from the user.
  • Then it asks the user if the temperature entered is in Celsius or in Fahrenheit scale (ask the user to enter c for Celsius and f for Fahrenheit.)
  • If the temperature entered is in Celsius, the application converts it to Fahrenheit and displays the Fahrenheit value (properly formatted) with an appropriate message. If the temperature entered is in Fahrenheit, the application converts it to Celsius and displays the Celsius value (properly formatted) with an appropriate message.
  • This application then asks if the user wants to continue to convert temperature. If the user enters y at the prompt, it repeats the process. If the user enters n at the prompt, it exits with an appropriate bye message.

[Do not use any built-in functions for the conversions. You are expected to create your own functions for the conversions and call them as needed.]

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

a)

Code:

#1.answer
saiL=[10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, 'python']
print("a. The given list is :\n",saiL)
print("b. The fourth element in the list is :\n",saiL[3])
print("c. The firs three values in the list is :\n",saiL[0:3])
print("d. Elements starting from the 6th element is :\n",saiL[5:])
saiL[len(saiL)-1]="unix"
print("e. The last element changed to :",saiL[len(saiL)-1])
print("The updated list is :\n",saiL)

  
  
b)

Code:

#2.answer...
saiT=(115, 'C#', 345)
print("\n\na. The given tuple is :\n",saiT)
print("b. The 2nd element of the tuple is :\n",saiT[1])
print("c. Try to change first value")
saiT[0]=345 #here we get error because tuples are immutable means that can't be changed

c)

Code:

#3.answer....
S=[1, 2, 3, 3, 4, 4, 5]
saiS=set(S)
print("The entire set is :\n",saiS)
print(saiS[2]) #here we get error because it doesn't support indexing
for i in saiS:
break
print("acessing element in different method")
print(i)

d)

Code:

#4.answer..
saiD={1: 'syed' , 'key':500}
print("a. Entire dictionary :\n",saiD)
print("b. verifying datatype :\n",type(saiD))
print("c. Value of key 1 is :\n",saiD[1])
print("c. Value of key \'key\' is :\n",saiD['key'])
print("d. Trying to print the value of john :\n",saiD['john'])
#here we get the error named keyError because key john is not in dictionary

e)

Code:

#5.answer....
print("Welcome to Temperature conversion program")
while(True):
temp=eval(input("Enter temperature"))
c_f=input("the temperature entered is in celcius(c) /Fahrenheit (c)")
if(c_f=='c'):
print("Temperature in Fahrenheit is:",(temp*(9/5))+32)
elif(c_f=='f'):
print("Temperature in celcius is:",((temp-32)*(5/9)))
else:
print("Invalid option")
op=input("contiue (y/n)?")
if(op=='n' or op=='N'):
break

Add a comment
Know the answer?
Add Answer to:
Create a Python list (use first three letters of your name followed by the letter L...
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
  • Write a Python program that uses a tuple. Create a tuple of your matric subjects. The...

    Write a Python program that uses a tuple. Create a tuple of your matric subjects. The program must display the first element, the last element, and the length of the tuple. An explanation message should also be included. E.g. The length of the tuple is 4. The user needs to be prompted for a subject, and the code needs to find the subject in the tuple. The user needs to be informed whether or not the subject is included in...

  • Python 5. Write a function named grade_components that has one parameter, a dictionary. The keys for...

    Python 5. Write a function named grade_components that has one parameter, a dictionary. The keys for the dictionary are strings and the values are lists of numbers. The function should create a new dictionary where the keys are the same strings as the original dictionary and the values are tuples. The first entry in each tuple should be the weighted average of the non-negative values in the list (where the weight was the number in the 0 position of the...

  • Process Create a City structure. The structure will hold the name of a city and its temperature. ...

    using C Process Create a City structure. The structure will hold the name of a city and its temperature. In the main function, read in a series of city names and their temperature expressed in Fahrenheit. Store the data in an array of City structures. Stop reading when either: The user enters the word "quit" for a city name, or The size of the array is about to be exceeded. Create a function that determines the highest temperature of the...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...

  • 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....

  • Python 3.7 Coding assignment This Program should first tell users that this is a word analysis...

    Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....

  • Python program Use the provided shift function to create a caesar cipher program. Your program s...

    python program Use the provided shift function to create a caesar cipher program. Your program should have a menu to offer the following options: Read a file as current message Save current message Type in a new message Display current message "Encrypt" message Change the shift value For more details, see the comments in the provided code. NO GLOBAL VARIABLES! Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR...

  • **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the...

    **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the creatures from the classic science-fiction film "The Day of the Triffids") is an algorithm that enciphers a plaintext message by encoding each letter as a three-digit number and then breaking up and rearranging the digits from each letter's encoded form. For this assignment, you will create a set of Python functions that can encode messages using this cipher (these functions...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • In Matlab. Use loops. 2. Create an algorithm to allow the user to enter a list...

    In Matlab. Use loops. 2. Create an algorithm to allow the user to enter a list of courses they have taken along with the grades received and the credit hours for each course, and then calculate the user's GPA. The program should first ask the user to type either Yes or No in response to the question, "Do you want to enter a grade?" If the answer is Yes, the user should be asked to enter the name of the...

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