1)
1)print(2*4*6*8*10*12*14*16*18*20.)
2)avg=(89+78+90+98)/4
3)print(3**7)
4)1_in=0.0833333333
foot=365*1_in
print(foot)
5)print(34567%17)
2)
animals = ['cat', 'dog', 'lion', 'tiger', 'monkey',
'hyena']
1)print(animals)
2)print('cat' in animals)
animals.append('wolf')
3)animals.append('bison')
print(animals)
4)animals.sort()
5)animals.remove("hyena")
6)print(len(animals))
animals.append('cow')
7)print(animals)
8)animals1=animals
print(animals1)
3)
numbers = [3456, 7865, 2341, 8907, 6798, 4576, 1098, 4320, 8905,
7812, 6453, 2341, 1994]
1)min(numbers)
2)max(numbers)
3)numbers.add(8654)
4)numbers.indexOf(7812)
5)numbers.append(1257)
6)numbers.count(2341)
7)sum(numbers)
8)len(numbers)
9)4321 in numbers
10)numbers.remove(4321)
11)numbers.pop()
12)len(numbers)
13)numbers.sort()
print(numbers)
14)numbers.reverse()
print(numbers)
4)
s="python programming"
print(s[17]=='g')
print(s[2]=='t')
print(s[0]==s[17])
print(s[6]==' ')
print('prog' in s)
print('mm' in s)
print(s.endswith('tion'))
print(s.startswith('py'))
5)
a,b,c=4,3,5
print(a**2+b**2==c**2)
6)
r=5
area=π*r**2
circumference=2*π*r
print(area)
print(circumference)
7)
first="first name"
last="last name"
print(first+last)
print(last+first)
8)
import math
print(-15<-9) ----------->TRUE
print(15==15.0)------->TRUE
print(-8+8==0)--------->TRUE
print(45/9==5)---------->TRUE
print(math.sqrt(25)==5.0)------->TRUE
print(4**2<=15)------->FALSE
print(3**3==9)------>FALSE
print(6-7>=0)-------->FALSE
print(34%4==4)------>FALSE
print(-3**2==-9)------>TRUE
9)
birds = ['crow', 'peacock', 'sparrow', 'dove', 'eagle',
'parrot', 'finch']
1)sublist1=birds[:3]
2)sublist2=birds[:2]
3)sublist3=birds[1:4]
4)sublist4=birds[3:5]
5)sublist5=birds[4:6]
please write these as you would into python. . i will give an thumbs ups 1....
write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : Alex got a sequence of n integers a1,a2,…,an as a birthday present. Alex doesn't like negative numbers, so he decided to erase the minus signs from all negative numbers. As a result, he got a sequence of non-negative numbers. Print the resulting sequence. For example, if the sequence is 1, 5, -3, 4,...
3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...
PYTHON
The first function you will write should be called ‘countDown’.
Your function should take zero (0) arguments. The function should
return one (1) list containing integers from 10 to 1 and finally,
the string “Liftoff!”. (i.e., [10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
‘Liftoff!’]). You function must be recursive (i.e., it should
contain a call to itself within the function body). You will get NO
credit if you use any loops (for, while, etc).
3. Function...
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:...
urgent help with python. can somone code this please and show
output
QUESTION: There are a variety of games possible with a deck of cards. A deck of cards has four different suits, i.e. spades (*), clubs (*), diamonds (), hearts (), and thirteen values for each suit. Now write a function that uses list comprehension to create a deck of cards. Each element in the list will be a card, which is represented by a list containing the suit...
Write in C++: Please create a shopping list using the STL list container, then follow the following instructions. Create an empty list. Append the items, "eggs," "milk," "sugar," "chocolate," and "flour" to the list. Print the list. Remove the first element from the list. Print the list. Insert the item, "coffee" at the beginning of the list. Print the list. Find the item, "sugar" and replace it with "honey." Print the list. Insert the item, "baking powder" before "milk" in...
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...
I need the following merge-sort assignment completed using the "ArrayList<Comparable>" (the part I'm really stuck on) with comments: import java.util.ArrayList; public class Mergesort { /** * Sorts list given using the mergesort algorithm * @param list the list to be sorted * @param first the index of the first element of the list to be sorted * @param last the index of the last element of the list to be sorted */ public static void mergesort(ArrayList<Comparable> list, int first, int...
write the solution of the program by python 3 language : I need the program using list : You are given a sequence of n positive integers a1,a2,…,an, where n is even. Swap adjacent elements in the given sequence and print the resulting sequence: a2,a1,a4,a3,a6,a5,… Input The first line contains a positive even integer n (2≤n≤1000) — the length of the sequence. The second line contains n space-separated integers a1,a2,…,an (1≤ai≤1000) — the elements of the sequence. Output Print n...
write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...