Write Python code examples of statements to remove the name at position 2 from the list in problem 32, and to remove one of the remaining names by referencing that name.
Write Python code to declare a tuple named stuck that holds the three remaining names from famfri by referencing those names as elemens of famfri.
Declare a Python set containing the names of the four seasons.
What happens if you declare a set using a list that contains two identical elements?
Declare a Python dictionary named myDict with at least three entries.
What is meant by the expression “implicit conversion”?
Write a Python if-elif-else construct that calls x() if a is true, y() if b is true but not a, and z() if c is true, but not a and not b, otherwise calling deadend().
Write a Python if statement that calls doWhat() if a and b is true or a and not c is true or e is equal to q.
Write an example of a Python for loop that uses a range.
Write an example of a Python for loop that iterates on the members
of a container such as a list.
NOTE: In order to answer the first three parts, you would need to provide the details of problem 32. Since you have not provided it, I have skipped those problems.
What happens if you declare a set using a list that contains two identical elements?
Answer: In this case, the set will contain only one instance of the duplicate element.
Declare a Python dictionary named myDict with at least three entries.
Answer:
myDict = {1: "One", 2: "Two", 3 : "Three"}
What is meant by the expression “implicit conversion”?
Answer: Implicit conversion means automatic type conversion to directly convert one data type to another.
Write a Python if-elif-else construct that calls x() if a is true, y() if b is true but not a, and z() if c is true, but not a and not b, otherwise calling deadend().
Answer:
if a is True:
x()
elif b is True:
y()
elif c is True:
z()
else:
deadend()
NOTE: As per Chegg policy I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.
Write Python code examples of statements to remove the name at position 2 from the list...
Write a Python if statement that calls doWhat() if a and b is true or a and not c is true or e is equal to q. Write an example of a Python for loop that uses a range. Write an example of a Python for loop that iterates on the members of a container such as a list. Show by code example in Python how to concatenate two strings and assign the result to a variable.
Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys() member function that returns a list of a dictionary's keys. You can check if a particular key is in a dictionary by using the in test with the keys list. For example, if our dictionary is MyDict = { 1: 'One', 2: 'Two', 3: 'Three' } Then ( 2 in MyDict.keys() ) evaluates to True, indicating that 2 is a valid key for MyDict....
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings as a parameter. The strings are intended to represent a person's first and last name (with a blank in between). Assume the last names are unique. The function should return a dictionary (dict) whose keys are the people's last names, and whose values are their first names. For example: >>> dictionary = names([ 'Ljubomir Perkovic', \ 'Amber Settle', 'Steve Jost']) >>> dictionary['Settle'] 'Amber' >>>...
Write a program that does the following in Python Code: Stores the following three lists: last_name = ["Smith", "Jones", "Williams", "Bailey", "Rogers", "Pyle", "Rossington"] first_name =["Lisa", "Bill", "Jay", "Sally", "Walter","Jake","Gary"] phone_number =["240-233-1921", "301-394-2745", "571-321-8934", "703-238-3432", "703-947-9987", "301-945-3593", "240-671-3221"] Has a function named combine_lists() that takes in last_names, first_names and phone_numbers as lists and returns a dictionary called phone_book that uses last_name as the key and a list consisting of first_name and phone_number. Has a main function that iterates through the...
Write a program that does the following in Python Code: Stores the following three lists: last_name = ["Smith", "Jones", "Williams", "Bailey", "Rogers", "Pyle", "Rossington"] first_name =["Lisa", "Bill", "Jay", "Sally", "Walter","Jake","Gary"] phone_number =["240-233-1921", "301-394-2745", "571-321-8934", "703-238-3432", "703-947-9987", "301-945-3593", "240-671-3221"] Has a function named combine_lists() that takes in last_names, first_names and phone_numbers as lists and returns a dictionary called phone_book that uses last_name as the key and a list consisting offirst_name and phone_number. Has a main function that iterates through the phone_book...
How to add class objects to a dictionary? *PYTHON ONLY* NO IMPORT RANDOM Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict (outside of the Employee class) that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses. The function should take the first value...
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 code: 1. This question practices the use of a list method. Assign to the variable grades a list of 10 letter grades from among ‘A’, ‘B’, ‘C’, ‘D’, and ‘F’. For example: grades = [‘A’, ‘F’, ‘C’, ‘F’, ‘A’, ‘B’, ‘A’, ‘C’, ‘A’, ‘B’] Write a Python expression that creates a list named frequency, in which the elements are the number of times each of the letters A, B, C, D and F appear in grades. For example, for...
Language: Python Topic: Tuples Function name : todo_tuple Parameters : todo (list of tuples of strings), completed (list of strings) Returns: final_list (list) Description : Write a function that takes in a list of tuples of strings that represents the work you have to do in each class, and a list of strings that represent the work you have already completed. Each tuple in the todo list represents the work for a single class. For this function, go through the...