Write python script that implementing the following: 1. Print PID of itself. 2. If the running OS is linux; print loadavg. 3. Take and print “5 min loadavg” value and cpu core count. If the loadavg value is near (or close) to the cpu core count (hint: nproc - 5min loadavg < 1) then exit script.

code in text
import os
import platform
print(" PID is:",os.getpid())
platfrom_name=platform.platform()
platfrom_name=platfrom_name.lower()
load_one_min, load_five_min, load_15_min= os.getloadavg()
if platfrom_name.find("linux")!=-1:
print("-------------load averge-------------------------------")
print("Load average over the last 1 minute:", load_one_min)
print("Load average over the last 5 minute:", load_five_min)
print("Load average over the last 15 minute:", load_15_min)
print("---------------------------------------------------------")
cpu_count=os.cpu_count()
print("Numbers of CPUs in the system is :", cpu_count)
print("Load average over the last 5 minute:", load_five_min)
if(cpu_count-load_five_min<0):
print(" exit the script ")
""" any doubt please comment if you like my answer please thumbs up"""
main.py saved 1 import os 2 import platform PID is: 1320 -------------load averge-------- Load average over the last 1 minute: 6.66 Load average over the last 5 minute: 4.72 Ldad average over the last 15 minute: 4.26 print(" PID is:",os.getpido) Numbers of CPUs in the system is : 4 Load average over the last 5 minute: 4.72 exit the script platfrom_name=platform.platform() platfrom_name=platfrom_name. lower() load_one_min, load_five_min, load_15_min= os.getloadavg() 9 11 if platfrom_name.find("linux") !=-1: print("-------------load averge-------------------------------") print("Load average over the last 1 minute: ", load_one_min) print("Load average over the last 5 minute: ", load_five_min) print("Load average over the last 15 minute:", load_15_min) print(" cpu_count=os.cpu_count) print("Numbers of CPUs in the system is : ", cpu_count) print("Load average over the last 5 minute:", load_five_min) if (cpu_count-load_five_minco): print(" exit the script") *" any doubt please comment if you like my answer please thumbs up **
Write python script that implementing the following: 1. Print PID of itself. 2. If the running...
Python programming Question 1: Write a script with a for loop that prints each character in your first name written as first initial capital and other small, followed by its ASCII value on the screen. Use appropriate functions to get character value to ASCII code. (Hint: Functions discussed in lectures) For example, the output of each iteration should be as -- for ‘A’, it should print A followed by its ASCII value. Question 2: Write a script that...
Python Script format please!
1. Write a script that takes in three integer numbers from the
user, calculates, and displays the sum, average, product, smallest,
and largest of the numbers input. Important things to note: a. You
cannot use the min() or max() functions, you must provide the logic
yourself b. The calculated average must be displayed as an integer
value (ex. If the sum of the three values is 7, the average
displayed should be 2, not 2.3333). Example:...
Use Python Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output. Basic math and string operations Calculate and print the final value of each variable. a equals 3 to the power of 2.5 b equals 2 b equals b + 3 (use +=) c equals 12 c = c divided by 4 (use /=) d equals the remainder of 5 divided by 3 Built-in functions abs, round, and...
Exercise 1 - Create a List to Sum Values Write a python script that sums the values in a list called add_list that contains the following values: (10, 2, -4, 8). Make sure you include a for loop when iterating through the list to sum the values. Take screenshots of the code and output. Exercise 2 – Create a Dictionary Write a python script that prints a dictionary where the key numbers are 1, 2, 3, 4, and 5 and...
Python)) Data types of Python. Write the python script to show the different examples. Write the Python script to present ALL the mathematical arithmetic operations. Write the Python script to display your - first name, last name, ID, college name and the program of study. Write the Python script to receive the number of seconds as input and display the hours, minutes and seconds as output. Assume the variable x to be with the string of "Day by day, dear...
Answer the following questions using linux 1) Write a Python script so that a file whoComesForDinner.txt formatted like this: Tuesday we have Joe McHungry and Paul McHungry Wednesday we have Cindy Johnston and Paul Paulsen Thursday we have Amin Mirzaei and Atefeh Mirzaei gets turned into that: The McHungry on Tuesday Cindy and Paul on Wednesday The Mirzaei on Thursday 2)Write a script that takes as argument a port number. It returns the next port that is not assigned to...
For this Linux script, answer the questions following it: # Sort lines 7 - 26 of the file BEGIN { idx = 1; while (getline line<"makefile" ) { data[idx] = line; idx++; } for (idx2 = 7; idx2 <= 26; idx2++) { data2[idx2 - 6] = data[idx2]; } count = asort(data2); for (idx3 = 1; idx3 < 7; idx3++) { print data[idx3]; } for (idx3 = 1; idx3 <= 20; idx3++) { print data2[idx3]; } for (idx3 = 27; idx3...
Write a python program to print a poem of your own choice. Then count how many words in each line, use a print statement to add the number of words in each line and display it. Hint: use print(3+5+4+6), for example. My poem: 'Tis better to have loved and lost Than never to have loved at all.'
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...
SHELL SCRIPT: Provide the following questions with the codes and command line Problem 5: Take 5 input arguments in a for loop, but only add the even i values to sum and display the result. Problem 6: Write a shell script that accepts path of the directory and returns a count of all the files within the specified directory. (Hint: use alias to perform cd operation) Problem 7: Write a shell script that takes an ‘count’ value as an input...