logic

Programming Logic using python 3.9

Programming Logic using python 3.9 Question: You decided to create a program to help your colleagues. Your program will receive as input two real numbers, the first representing the grade of papers and the second the grade of the regular exam. Considering that each of the two grades represents 50% of the final average, your …

Total answers: 1

Python Questionnaire Validation with Recursion

Python Questionnaire Validation with Recursion Question: I’ve created a function in Python to review a series of questions in a dictionary and remove records from the dataset depending on the answers to the questionnaire. I’ve created the questionnaire so the user can only respond yes or no. I have a third branch to handle the …

Total answers: 2

trouble calculating the amount of Sundays inbetween 2 dates

trouble calculating the amount of Sundays inbetween 2 dates Question: I was asked to create a program that calculates the number of Sundays inbetween 2 dates! I have been searching numerous articles and documentation but I still have a hard time understanding syntax. (2 months into my coding course with 0 technology and computer experience.) …

Total answers: 2

Why doesn't the "and" condition work in my Python codes?

Why doesn't the "and" condition work in my Python codes? Question: Each separate statement is true, but why is the combination of the two with "and" false? codes Asked By: ZHONGLI WANG || Source Answers: In python and is a logical AND that returns True if both the operands are true whereas ‘&’ is a …

Total answers: 2

maximum difference in the summation of two subset

maximum difference in the summation of two subset Question: I have an array with N elements. I have to divide the array into two subset such that one subset has exactly M elements and the other subset has the rest. Dividing the items into subset in a way such that the difference in the summation …

Total answers: 2

unexpected output in python change in my variable

unexpected output in python change in my variable Question: I want to print a dict – if name in ans[‘stderr’] then output dict containing complete = False else stderr to be data = [] names = ["abc", "xyz"] ans = { ‘complete’: True, ‘stdout’: ”, ‘stderr’: "if XYZ complete must be False else stderr should …

Total answers: 1

Why is numpy.ndarray([0]).all() returning True while numpy.array([0]).all() returning False?

Why is numpy.ndarray([0]).all() returning True while numpy.array([0]).all() returning False? Question: This seems surprising to me: import numpy as np assert np.ndarray([0]).all() assert not np.array([0]).all() What is going on here? Asked By: Intrastellar Explorer || Source Answers: Consider what those two calls produce: >>> np.ndarray([0]) array([], dtype=float64) This is an empty 1-D array, because you specified …

Total answers: 1