Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

5. Groupings

by CodeChum Admin

Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.


Instructions:

  1. Create a variable that accepts a positive odd integer.
  2. Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
  3. Reverse the order of the list. Then, print out the list's new order in this manner:
  4. [first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.

Input

The first line contains an odd positive integer.

The next lines contains an integer.

5
1
3
4
5
2

Output

A line containing a list.

[2,5]-[4]-[3,1]




1.Start


2.Initialize Sum , Count to 1 ( Sum = 1 , Count = 1 )


3.Enter a temp


4.Add Temp to sum. ( Sum = Temp + Sum )


5.Increase Counter by 1 ( Count = Count + 1)


6.Repeat step 3 through 5 , Ten times


7.Calculat average temp in Fahrenheit (Average temp = (( sum * 9 / 5 ) + 32 ) / 10 )


8.If t Average temp is more than or equal to 97 and Average temp is less than or equal to 99 then Display “Your body temperature is normal”


9.Else Average temp is more than to 100.4 then Display “You have a fever caused by an infection or illness”


10.End.



Do Exercise 6.4 from your textbook using recursion and the is_divisible function from Section 6.4. Your program may assume that both arguments to is_power are positive integers. Note that the only positive integer that is a power of "1" is "1" itself.

After writing your is_power function, include the following test cases in your script to exercise the function and print the results:

print("is_power(10, 2) returns: ", is_power(10, 2))

print("is_power(27, 3) returns: ", is_power(27, 3))

print("is_power(1, 1) returns: ", is_power(1, 1))

print("is_power(10, 1) returns: ", is_power(10, 1))

print("is_power(3, 3) returns: ", is_power(3, 3))

You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Don’t forget to include descriptive comments in your Python code.



Take two numbers (separated by a space) as user input in a single line



which will be used as a range (both numbers inclusive) later. Your task is



to create and print a Python dictionary where the keys will be numbers from



that range and the corresponding values will be the odd factors (divisors)



of that number in a tuple.




Write a program on write an algorithm to find the total number of units of memory allocated or dellocated by the senser 1 after processing all the request


Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.Input


Write a program (source code) for Fault tree analysis of all circumstances.

Write a program which creates a class named babyRecord with four methods.

a) One method will be used to write details of a child including date of birth, name, parent

names and hospital name into a file called baby_data.txt.

b) The second method will be used to read from the file baby_data.txt and store the data in a

dictionary called records.

c) The third method will be used to search for a baby using baby name or parent names

information in the file called baby_data.txt.

d) The last method will be used to delete records in the dictionary and file respectively.

e) Clearly show how exceptions are handled in your program in each method.


Demonstrate use of Object Oriented Programming (OOP) principles, data structures and file

handling operations to carry out the following tasks:

a) Define a class named Person, with child classes named Daughter and Son who also have

have derived classes named GrandSon and GrandDaughter respectively. All child

classes have derived genetic features and skills from Person. Create 5 methods for

getting and setting genetic features, setting and getting skills and demonstrate the concept

of polymorphism.

b) Modify the answer in a) and show how the person features are captured in a file called

person.txt. Also create another method to read from the file person.csv and store the data

in a list called persondata. Clearly show how exceptions are handled in your program.


Describe each possibility in your own words.



LATEST TUTORIALS
APPROVED BY CLIENTS