Categories
Mastering Development

How to use a cut in prolog to find the number of daughters?

Exercise: Observe the family structure below where each person has a gender specification as their third parameter (m = male, f = female). Use a cut to write the predicate numDaughters(L, Count) in such a way that family(Husband, Wife, Kids), numDaughters([Husband, Wife|Kids],X) lists each family in the database and the number of daughters in each […]

Categories
Mastering Development

Recreate Excel formula in SQL

I am trying to recreate the below Excel formula/table and have True/False display but am stuck. Excel Formula: =ABS(ROUND(MEDIAN(C$2:C2),0)-ROUND(MODE.SNGL(C$2:C2),0))<[sample.xlsx]variables!$B$2 I have 200+ rows of data and I need the Median and the Mode only calculated from the first row to the current row. I can create the Median for all rows in SQL, but this […]

Categories
Mastering Development

Encoding Issues when reading R Object

I am reading an R object with the readRDS. It should have two columns, a year and a character string. For most rows, the character string is OK, but some have a strange white blob and others seem to have a character vector with escaped special characters and some have special characters like â. I […]

Categories
Mastering Development

How to add or update info to an existing list in python

All I want to do is to populate a list of unique customers with their corresponding year of birth. Most so to write it back to my df to fill those empty spaces. Both John and Mike’s names appear twice on the list. John provided his year of birth the first time he purchased an […]

Categories
Development

How can I find the largest increase in value of the elements of this list and then return the corresponding year and actual value it increased by

MIDYEAR_POPULATION = [(1971, 21962032), (1972, 22218463), (1973, 22491777), (1974, 22807969), (1975, 23143275), (1976, 23449808), (1977, 23725843), (1978, 23963203), (1979, 24201544), (1980, 24515667), (1981, 24819915), (1982, 25116942), (1983, 25366451), (1984, 25607053), (1985, 25842116), (1986, 26100278), (1987, 26446601), (1988, 26791747), (1989, 27276781), (1990, 27691138), (1991, 28037420), (1992, 28371264), (1993, 28684764), (1994, 29000663), (1995, 29302311), (1996, 29610218), (1997, […]

Categories
Development

How can I find the largest increase in value of the elements of this list and then return the corresponding year and actual value it increased by

MIDYEAR_POPULATION = [(1971, 21962032), (1972, 22218463), (1973, 22491777), (1974, 22807969), (1975, 23143275), (1976, 23449808), (1977, 23725843), (1978, 23963203), (1979, 24201544), (1980, 24515667), (1981, 24819915), (1982, 25116942), (1983, 25366451), (1984, 25607053), (1985, 25842116), (1986, 26100278), (1987, 26446601), (1988, 26791747), (1989, 27276781), (1990, 27691138), (1991, 28037420), (1992, 28371264), (1993, 28684764), (1994, 29000663), (1995, 29302311), (1996, 29610218), (1997, […]

Categories
Development

If else statement with 4 years variable including knowing which year it is

So the question stated is: There is year 1950-2050 and we have the olympic games and football/soccer world championship. The program should be able to tell which one it is based from these two variables and how the program should know is from the year between 1950-2050. The program should also be able to tell […]

Categories
Development

If else statement with 4 years variable including knowing which year it is

So the question stated is: There is year 1950-2050 and we have the olympic games and football/soccer world championship. The program should be able to tell which one it is based from these two variables and how the program should know is from the year between 1950-2050. The program should also be able to tell […]