Question

In: Computer Science

use python 1. Write a program that a. defines a list of countries that are members...

use python

1. Write a program that a. defines a list of countries that are members of BRICS (Brazil, Russia, India, China, Sri Lanka) b. Check whether a country is a member of BRICS or not Program run Enter the name of country: Pakistan Pakistan is not a member of BRICS Enter the name of country : India India is a member of BRICS

2. Write a program to create a list of numbers in the range of 1 to 10. Then delete all the even numbers from the list and print the final list. def makeList() – function to create the list of numbers from 1 to 10 def delEven() – function to delete even numbers from list def main()‐ call the above functions and print Original List – [1,2,3,4,5,6,7,8,9,10] List after deleting even numbers: [1,3,5,7,9]

Solutions

Expert Solution

1)

#define countries
countries=['Brazil','Russia','India','China','Sri Lanka']
#input country name
countryName=input("Enter the name of country: ")
if countryName in countries:
   print(countryName,"is a member of BRICS")
else:
   print(countryName,"is not a member of BRICS")

Output

Enter the name of country: Pakistan
Pakistan is not a member of BRICS

Enter the name of country: India
India is a member of BRICS

2)

def makeList():
   l=[]
   for i in range(1,11):
       l.append(i)
   return l
def delEven(l):
   i=0
   while i<len(l):
       if l[i]%2==0:
           l.remove(l[i])
       i+=1
   return l
l=makeList()
print("Original List -",l)
print("List after deleting even numbers:",delEven(l))

Output

Original List - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
List after deleting even numbers: [1, 3, 5, 7, 9]


Related Solutions

1. Write a Python program that performs the following: 2. Defines an array of integers from...
1. Write a Python program that performs the following: 2. Defines an array of integers from 1 to 10. The numbers should be filled automatically without the need for user inputs 3. Find the sum of the numbers that are divisible by 3 (i.e., when a number is divided by 3, the remainder is zero) 4. Swap the positions of the maximum and minimum elements in the array. First, you need to find the maximum element as shown in the...
1. Write a python program to create a list of integers using random function. Use map...
1. Write a python program to create a list of integers using random function. Use map function to process the list on the expression: 3x2+4x+5 and store the mapped elements in another list. Now use filter to do sum of all the elements in another list. 2. Write a function that takes n as input and creates a list of n lists such that ith list contains first 10 multiples of i. 3. Write a function that takes a number...
IN PYTHON: Write a program to study countries and their capitals. The program will store country:capital...
IN PYTHON: Write a program to study countries and their capitals. The program will store country:capital information and allow the user to quiz themselves. These two functions are required for this assignment. You may add other functions that you deem appropriate: - menu()   This function, which displays all the user options to the screen, prompts the user for their choice and returns their choice. This function will verify user input and ALWAYS return a valid choice. - addCapital(dict) This function...
Write a program in python such that There exists a list of emails List Ls =...
Write a program in python such that There exists a list of emails List Ls = ['xyz@tz.ac.in','sachin.s@gail.com','avinash.paul@hotmail.com','rohan.d@xyz.ac.in',test@zx.ac.in.co'] Count the number of emails IDS which ends in "ac.in" Write proper program with proper function accepting the argument list of emails and function should print the number of email IDs and also the email IDS ending with ac.in output 2 xyz@tz.ac.in rohan.d@xyz.ac.in ================================= i am trying like this but getting confused len [True for x in Ls if x.endswith('.ac.in')] please write complete...
for Python 3 Write a python program that Creates a list that has these values in...
for Python 3 Write a python program that Creates a list that has these values in this order, 'Python', 'JavaScript', and 'PHP' Define a displayMyClasses function that sorts the list and then displays each item on the list, one per line, in sorted order. Also, number the displayed list as shown in the "Running a Sample Program" shown below. Define a guessNext function that selects a random element from the list and returns it to the call of the function....
1)  Write a python program that opens a file, reads all of the lines into a list...
1)  Write a python program that opens a file, reads all of the lines into a list of strings, and closes the file. Use the Readlines() method. Test your programing using the names.txt file provided. 2) Convert the program into a function called loadFile, that receives the file name as a parameter and returns a list of strings. 3) Write a main routine that calls loadFIle three times to load the three data files given into three lists. Then choose a...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out your name and PRINTS OUT any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and PRINTS OUT a message telling if the numberer is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one parameter, a number,...
(PYTHON) Write a program: This assignment will give you more experience on the use of: 1....
(PYTHON) Write a program: This assignment will give you more experience on the use of: 1. integers (int) 2. floats (float) 3. conditionals 4. iteration The goal of this project is to make a fictitious comparison of the federal income. You will ask the user to input their taxable income. Use the income brackets given below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider individuals and not married...
Write a Python program that performs the following list operations. Part A Define a list called...
Write a Python program that performs the following list operations. Part A Define a list called numList with elements. 84, 94, 27, 74, 19, 90, 16, 21, 56, 50, 77, 59, 41, 63, 18, 26, 80, 74, 57, 30, 40, 93, 70, 28, 14, 11, 43,65, 91, 83, 22, 53, 74, 44, 73, 55, 47, 74, 81 Display the followings: All the numbers in numList The number of elements in numList The smallest number in numList The largest number in...
#Write a program in Python that given a list of positive integers, return another list where...
#Write a program in Python that given a list of positive integers, return another list where each element corresponds to the sum of the digits of the elements o#f the given list. #Example: # input # alist=[124, 5, 914, 21, 3421] # output # sum=[7, 5, 14, 3, 18]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT