In the python: Note 1: You may not use these python built-in functions: sorted(), min(), max(), sum(), pow(), zip(), map(), append(), count() and counter().
For questions 1, 2 and 4: Ask the user to enter the size of a list. Fill the list with random numbers 0-9 and print the list. 1- (8 points) luckyNumbers.py: Find the sum of the numbers in a list, except the number 7 is considered unlucky, so we ignore it and do not include 7's in the sum. Print the list, the sum of lucky numbers that are not 7, and the number of 7's found in the list. Sample run: Enter the number of numbers to create : 6 Numbers : [6, 8, 4, 6, 6, 6] Found 0 sevens. Sum of lucky numbers = 36 Sample run: Enter the number of numbers to create : 6 Numbers : [4, 2, 7, 3, 7, 7] Found 3 sevens. Sum of lucky numbers = 9
import random#import random
n=int(input("enter the size of list "))#asks user to enter the size of list
str1=""#initialize str1="" and value=0
value=0
for i in range(n):#loop runs till n
x=random.randint(0,9)#x contains any random value between 0 to 9
str1=str1+str(x)#it converts x to string and concatenates with the string
list1=[]#empty lsit
list1=list(str1)#convert str1 to list assign it to the list1
print(list1)
for i in range(len(list1)):#for loop which runs till len(list1)
if((int(list1[i]))!=7):#if the element is not equal to 7 then add it to the vale
value=value+int(list1[i])
print(value)#it prints the value


In the python: Note 1: You may not use these python built-in functions: sorted(), min(), max(),...
Rules: You may NOT use the following built-in functions. sort() sum() max() min() Except for format() all string methods are banned. Except for append() and extend() all list methods are banned. You may not import any module. Make sure to test your code with a variety of inputs. Do not assume the examples in these directions are reflective of the hidden test cases. Part 3 Echo (5 Points) Write a function called echo that takes as argument a list and...
Python Homework: - NOTE - Must not use built-in functions (other than the range() function), slice expressions, list methods (other than the append() method) or string methods in your solution. Write a function called reverse(my_list, number=-1) that takes a list and a number as parameters. The function returns a copy of the list with the first number of items reversed. Conditions: - The number parameter must be a default argument. - If the default argument for number is given in...
python #Ignore line 2, it is just there to align with zybooks requirements print("5") #Create a list with the following numbers and assign it to a variable name: 1,2,3,4,5,6 #Convert the list to a tuple and assign it to a variable name (dirrerent from the list's name) #Try the following and press the run program button to which ones work and which ones cause errors #If a statement causes an error, use a # to comment it out #Add the...
In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while loop or a for loop to print only odd numbers 1, 3, 5, 7, 9 *tip: you can use range () function, or a condition with ‘break’ (e.g, while count < 10) In python!: Create a program that print out 12 months of a year and associated numbers (e.g., January 1, February 2…). Two lists should be created, and then loop through the list...
please write these as you would into python. . i will give an thumbs ups 1. Evaluate the following expressions using Python 1. Product of first 10 even integers. 2. Midterm scores of 4 students are 89, 78, 90, 98. Find the average of these scores. 3. Evaluate 3 to the power 7 4. Find the number of foot in 345 inches. 5. find the remainder when 34567 divides by 17. 2. animals = ['cat', 'dog', 'lion', 'tiger', 'monkey', 'hyena']...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...
Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...
1. What is the result of calling the append method on a list? 2. What must be defined prior to using a method like append? 3. Explain why two lines caused an IndexError. 4. What is the result of calling the remove method on a list? 5. Give one example of a list method that requires an argument and one that does not. 6. Describe the syntax similarities and differences between using a list method like append and Python built-in...
use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...