[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.]
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
Create a Python list (use first three letters of your name followed by the letter L...
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 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...
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 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 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 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 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 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 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 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...