This is for Python
numbers = [7, 3, 6, 9, 0]
print(numbers.sort())
Output: [0, 3, 6, 7, 9]
numbers = [7, 3, 6, 9, 0]
print(numbers.sort(reverse = True))
Output: [9, 7, 6, 3, 0]
Answer:
You use parentheses around the data values.
Explanation:
j took the test on edge
Answer:
Stick to concrete nouns
Explanation:
The best technique to improve the web search result is that search with the help of keywords. These keywords help in searching the required results from search engines.
The keywords are actually nouns. Noun is name of object, place or person. So by using nouns we can search out required results.
For example
If we want to search about some persons bibliography, we use his name in our search. His name is an example of noun.
Answer:
def select_short_strings(string_list):
new_list = []
for s in string_list:
if len(s) < 20:
new_list.append(s)
return new_list
lst = ["apple", "I am learning Python and it is fun!", "I love programming, it is easy", "orange"]
print(select_short_strings(lst))
Explanation:
- Create a function called <em>select_short_strings</em> that takes one argument <em>string_list</em>
Inside the function:
- Initialize an empty list to hold the strings that are less than 20
- Inside the loop, check the strings inside <em>string_list</em> has a length that is smaller than 20. If found one, put it to the <em>new_list</em>.
- When the loop is done, return the <em>new_list</em>
- Create a list to check and call the function
Answer:
In Python:
import os.path
from os import path
fname = input("Filename: ")
if path.exists(fname):
with open(fname) as file_in:
lines = []
for line in file_in:
lines.append(line.rstrip('\n'))
f = open("stat.txt","r+")
f.truncate(0)
f = open("stat.txt", "a")
f.write("Names\tTotal\tSubjects\tAverage\n")
for i in range(len(lines)):
rowsum = 0; count = 0
nm = lines[i].split()
for j in nm:
if (j.isdecimal()):
count+=1
rowsum+=int(j)
average = rowsum/count
f.write(nm[0]+"\t %3d\t %2d\t\t %.2f\n" % (rowsum, count, average))
f.close()
else:
print("File does not exist")
Explanation:
See attachment for explanation where comments were used to explain each line