Answer:
def readFile(filename):
dict = {}
with open(filename, 'r') as infile:
lines = infile.readlines()
for index in range(0, len(lines) - 1, 2):
if lines[index].strip()=='':continue
count = int(lines[index].strip())
name = lines[index + 1].strip()
if count in dict.keys():
name_list = dict.get(count)
name_list.append(name)
name_list.sort()
else:
dict[count] = [name]
print(count,name)
return dict
def output_keys(dict, filename):
with open(filename,'w+') as outfile:
for key in sorted(dict.keys()):
outfile.write('{}: {}\n'.format(key,';'.join(dict.get(key))))
print('{}: {}\n'.format(key,';'.join(dict.get(key))))
def output_titles(dict, filename):
titles = []
for title in dict.values():
titles.extend(title)
with open(filename,'w+') as outfile:
for title in sorted(titles):
outfile.write('{}\n'.format(title))
print(title)
def main():
filename = input('Enter input file name: ')
dict = readFile(filename)
if dict is None:
print('Error: Invalid file name provided: {}'.format(filename))
return
print(dict)
output_filename_1 ='output_keys.txt'
output_filename_2 ='output_titles.txt'
output_keys(dict,output_filename_1)
output_titles(dict,output_filename_2)
main()
Explanation:
Answer:
def future_investment_value(investment, monthly_interest_rate, years):
print("Years\tFuture Value")
print("- - - - - - - - - - -")
for i in range(1, years+1):
future_value = investment * ((1 + monthly_interest_rate) ** (12 * i))
print(i, "\t\t", format(future_value, ".2f"))
investment = float(input("Enter the invesment amount: "))
interest = float(input("Enter the annual interest rate: "))
year = int(input("Enter the year: "))
future_investment_value(investment, interest/1200, year)
Explanation:
Inside the function:
- In the for loop that iterates through the years, calculate the future value using the formula and print the results
Then:
- Ask the user for the investment, annual interest rate, and year
- Call the function with the given inputs
Answer:
vowels = ("a", "e", "i", "o", "u")
word = input("Enter a word: ")
is_all = True
for c in vowels:
if c not in word:
is_all = False
if is_all == True:
print(word + " is a vowel word.")
else:
print(word + " is not a vowel word.")
Explanation:
Initialize a tuple, vowels, containing every vowel
Ask the user to enter a word
Initially, set the is_all as True. This will be used to check, if every vowel is in word or not.
Create a for loop that iterates through the vowels. Inside the loop, check if each vowel is in the word or not. If one of the vowel is not in the vowels, set the is_all as False.
When the loop is done, check the is_all. If it is True, the word is a vowel word. Otherwise, it is not a vowel word.
b. /etc/fstab
c. /var/filesystem
d. /boot/config
Answer:
B. /etc/fstab file.
Explanation:
The /var/filesystem file is a subdirectory of the root directory of a linux operating system, used to store files during the operation of a computer system.
The /boot/config file is a file directory used to store system configuration parameters which can be accessed by the GPU before the installation of the ARM CPU and linux.
The /etc/mount (or /etc/mtab) and /etc/fstab are used to show the list of mounted volumes. The /etc/mtab gives details of already mounted volumes, but the /etc/fstab shows the list of possible volumes to be mounted upon the boot of the system.
Answer:
C++.
Explanation:
#include <iostream>
using namespace std;
////////////////////////////////////////////////////////////////
void printPrime(int n) {
if (n > 0) {
cout<<2<<endl;
for (int i=3; i<=n; i++) {
bool isPrime = true;
for (int j=2; j<i; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime == true)
cout<<i<<endl;
}
}
else {
cout<<"Invalid input";
}
}
int main() {
int n;
cout<<"Enter positive integer: ";
cin>>n;
printPrime(n);
return 0;
}
Answer:
the answer is c
Explanation:
i just took the test
Answer:c
Explanation: because Diagnosing looks for the nature of the problem, while troubleshooting attempts to identify the source of the problem.