Answer:
See explaination
Explanation:
def readFileFirstLast(filename):
# doc string
''' Function accept the filename and opens the fle
and reads all lines and strips new line character and
stores first and last in a string and return that string'''
#eception handle if file not found
try:
#opening the file
f = open(filename)
#reading the first line and striping the ne line
string = f.readline().strip()
#iterating until last line
for line in f:
pass
#concate the last line after strip the new line character to the string
string = string + " " + line.strip()
#return the string
return string
except:
#if file not found
return "File not found"
#taking the file name from user
filename = input("Enter a file name: ")
#printing the doc string in function
print("\ndoc_sting: \n"+ readFileFirstLast.__doc__+"\n")
#printing the returned string by calling the readFileFirstLast()
print("output string :")
print(readFileFirstLast(filename))
13? 13 is most minimum ages however, I don't understand this question all that well.
Answer:
CPU, input unit, Output unit, memory unit
<u> C++ Program to Print Pascal's Triangle</u>
#include<iostream>
//header file
using namespace std;
//driver function
int main()
{
int r;/*declaring r for Number of rows*/
cout << "Enter the number of rows : ";
cin >> r;
cout << endl;
for (int a = 0; a < r; a++)
{
int value = 1;
for (int b = 1; b < (r - a); b++)
/*Printing the indentation space*/
{
cout << " ";
}
for (int c = 0; c <= a; c++)
/*Finding value of binomial coefficient*/
{
cout << " " << value;
value = value * (a - c) / (c + 1);
}
cout << endl << endl;
}
cout << endl;
return 0;
}
<u>Output</u>
<u>Enter the number of rows : 5</u>
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1