Why does this not work?(school project btw) - input

import sys,time,random
typing_speed = 80 #wpm
def slow_type(t):
for l in t:
sys.stdout.write(l)
sys.stdout.flush()
time.sleep(random.random()*10.0/typing_speed)
slow_type("Hello which person do you want info for ")
inputs = input(
"Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar ")
if inputs == ('1'):
inputs = input(
"what info do you want. 1. overall life 2. accomplishments and obstacles. 3. His legacy "
)
if inputs == ('1'):
slow_type(
"born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher, he left the NOI to make a new group because he embraced a different type of Islam, sunni islam, he died in febuary 21 on 1965 by assasins who were part of the NOI."
)
elif inputs == ('2'):
slow_type(
"Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back. "
)
if inputs == ('2'):
inputs = input(
"what info do you want. 1. Birth and age 2. Early Life. 3. Nba life 4. Later Life 5. Accomplishments and Accolades"
)
if inputs == ('1', '2', '3', '4', '5'):
if inputs == ('1'):
slow_type(
"Kareem was born in New York during 1947 on the day of April 16th with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
)
if inputs == ('2'):
slow_type(
"Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
)
if inputs == ('3'):
slow_type(
"In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
)
if inputs == ('4'):
slow_type("o")
To be specific the info doesn’t print for some reason pls help owo uwu I’m a furry cat girl

It doesn't work because your logic.
if inputs == ('1', '2', '3', '4', '5'): will always return False as your inputs variable will never be that tuple. You are also overwriting the inputs variable and I would consider renaming those distinct.
I made a few changes in there. Take a look and compare it to your code. This code is working just fine (relative to what you provided).
import sys,time,random
typing_speed = 80 #wpm
def slow_type(t):
print('\n')
for l in t:
sys.stdout.write(l)
sys.stdout.flush()
time.sleep(random.random()*10.0/typing_speed)
slow_type("Hello which person do you want info for?")
inputs_alpha = input(
"Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar\n--> ")
if inputs_alpha == '1':
inputs = input(
"what info do you want?\n1. overall life\n2. accomplishments and obstacles.\n3. His legacy\n--> "
)
if inputs == '1':
slow_type(
"born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher, he left the NOI to make a new group because he embraced a different type of Islam, sunni islam, he died in febuary 21 on 1965 by assasins who were part of the NOI."
)
elif inputs == '2':
slow_type(
"Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back. "
)
if inputs_alpha == '2':
inputs = input(
"what info do you want?\n1. Birth and age\n2. Early Life.\n3. Nba life\n4. Later Life\n5. Accomplishments and Accolades\n--> "
)
if inputs in ['1', '2', '3', '4', '5']:
if inputs == '1':
slow_type(
"Kareem was born in New York during 1947 on the day of April 16th with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
)
if inputs == '2':
slow_type(
"Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
)
if inputs == '3':
slow_type(
"In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
)
if inputs == '4':
slow_type("o")

Related

Aggregate data based on values appearing in two columns interchangeably?

home_team_name away_team_name home_ppg_per_odds_pre_game away_ppg_per_odds_pre_game
0 Manchester United Tottenham Hotspur 3.310000 4.840000
1 AFC Bournemouth Aston Villa 0.666667 3.230000
2 Norwich City Crystal Palace 0.666667 13.820000
3 Leicester City Sunderland 4.733333 3.330000
4 Everton Watford 0.583333 2.386667
5 Chelsea Manchester United 1.890000 3.330000
The home_ppg_per_odds_pre_game and away_ppg_per_odds_pre_game are basically the same metric. The former reprsents the value of this metric for the home_team, while the latter represents this metric for the away team. I want a mean of this metric for each team and that is regardless whether the team is playing home or away. In the example df you Manchester United as home_team_name in zero and as away_team_name in 5. I want the mean for Manchester United that includes all this examples.
df.groupby("home_team_name")["home_ppg_per_odds_pre_game"].mean()
This will only bring me the mean for the occasion when the team is playing home, but I want both home and away.
Since the two metrics are the same, you can append the home and away team metrics, like this:
data_df = pd.concat([df.loc[:,('home_team_name','home_ppg_per_odds_pre_game')], df.loc[:,('away_team_name','away_ppg_per_odds_pre_game')].rename(columns={'away_team_name':'home_team_name','away_ppg_per_odds_pre_game':'home_ppg_per_odds_pre_game'})])
Then you can use groupby to get the means:
data_df.groupby('home_team_name')['home_ppg_per_odds_pre_game'].mean().reset_index()

Updating a Table in Access Using VBA and SQL for a Forecasting Process

So my question deals with a series of forms and buttons that prompts the user to put in information for a forecasting process. When they click on the update button, it stores it into a table. However, what I need to be able to do is take what is in that table, search for the most recent record, and then append that data to another table. Sounds simple enough, but it gets a little more complicated, to me at least.
So the way the records are stored are by a date and month value which looks like this YYMM (so if it was September 2019 it would look like 1809). I want to be able to make a button that the user can press on a monthly basis checking to see the most recent records and posting that for the rest of the year.
This is hard to explain over text, but I will do my best. The user presses the button to update the second table and its looking at each record and updating every instance after the most recent occurrence.
Here's what it would look like visually with goofy names for the columns:
Table 1, the one the user is updating at random
DATE Animal_ID Species Breed Treats
1807 000342 Dog Lab 5
1806 002342 Cat Tabby 20
So obviously there would be more records, but it would look random like that.
Here's table 2, the one that is keeping track of forecasting.
DATE Animal_ID Species Breed Treats
1801 000342 Dog Lab 3
1802 000342 Dog Lab 3
1803 000342 Dog Lab 3
1804 000342 Dog Lab 3
1805 000342 Dog Lab 3
1806 000342 Dog Lab 3
1807 000342 Dog Lab 3
1808 000342 Dog Lab 3
1809 000342 Dog Lab 3
1810 000342 Dog Lab 3
1811 000342 Dog Lab 3
1812 000342 Dog Lab 3
1801 002342 Cat Tabby 2
1802 002342 Cat Tabby 2
....
I'm not sure if that makes sense, but the second table already will exist with prepopulated data. So if the user pressed the append button, it should then replace everything 1807 and after for the dog with that data, and everything 1806 and after for the cat.
Like I said, not the easiest to explain, but I hope I got some of what I'm trying to do across. I'd be more than happy to elaborate more if necessary.
Thanks
Create one query where you get a list of the Animal_ID and the highest date.
Create another query containing the forecast table and the query above, joining on the animal_id and date.

I need to get the min, max, avg of an Array List using Java

The values come from a Junit test case or from a scanner, so the method has to work in all scenarios. The array List looks something like this.
Utah 5
Nevada 6
California 12
Oregon 8
Utah 9
California 10
Nevada 4
Nevada 4
Oregon 17
California 6
I need to be able to calculate the average of, let's say, Utah. I know how to do something that finds the average. My biggest problem is knowing how to only get values from the names of Utah rather than just getting all of them.
names=states values= numbers categories=what
you are calculating
here is the start of the method:
public static ArrayList<Double> summarizeData (ArrayList<String> names, ArrayList<Double> values ,ArrayList<String> categories, int operation)

How to identify and split a paragraph or merged text into sub parts in Word document having list of decimal, alphabet, roman, and sub points

We regularly get closed text/merged text in Word document
It will have numerical numbering (1 to 10).
For example this is the text containing 7 points. I want it to be splitted into sub parts.
AGENDA OF THE MEETING
1.OPENING OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS. 2.ELECTION OF THE CHAIRPERSON OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS. 3.PREPARATION OF THE ATTENDANCE LIST, ACKNOWLEDGEMENT THAT THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS HAS BEEN CONVENED APPROPRIATELY AND IS CAPABLE OF ADOPTING BINDING RESOLUTIONS. 4.ADOPTION OF THE AGENDA OF THE EXTRAORDINARY GENERAL MEETING. 5.ADOPTION OF THE RESOLUTION REGARDING THE SALE OF AN ORGANISED PART OF ENTERPRISE. 6.ADOPTION OF THE RESOLUTION AMENDING THE COMPOSITION OF THE SUPERVISORY BOARD OF THE BANK. 7.CLOSING OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS
Result:
1.OPENING OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS.
2.ELECTION OF THE CHAIRPERSON OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS.
3.PREPARATION OF THE ATTENDANCE LIST, ACKNOWLEDGEMENT THAT THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS HAS BEEN CONVENED APPROPRIATELY AND IS CAPABLE OF ADOPTING BINDING RESOLUTIONS.
4.ADOPTION OF THE AGENDA OF THE EXTRAORDINARY GENERAL MEETING.
5.ADOPTION OF THE RESOLUTION REGARDING THE SALE OF AN ORGANISED PART OF ENTERPRISE.
6.ADOPTION OF THE RESOLUTION AMENDING THE COMPOSITION OF THE SUPERVISORY BOARD OF THE BANK.
7.CLOSING OF THE EXTRAORDINARY GENERAL MEETING OF SHAREHOLDERS
Can you provide a macro to separate/split. The numbering will execute 1 , 2....103, 104 etc Please help.
Coming to second question if the numbering is in Romans (I, II, III, IV ) and in alphabet (A, B, C, D) form how to create a macro to split those:
EXAMPLE TEXT:
Numbering as alphabets
A. Presentation of the financial statements and annual report for the 2010 financial year with the report of the Supervisory Board, the group financial statements, the group annual report, and the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code B. Ratification of the acts of the Board of MDs C. Ratification of the acts of the Supervisory Board D. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt E. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi (3) Andrea Sieber
Output:
A. Presentation of the financial statements and annual report for the 2010 financial year with the report of the Supervisory Board, the group financial statements, the group annual report, and the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code
B. Ratification of the acts of the Board of MDs
C. Ratification of the acts of the Supervisory Board
D. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt
E. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi (3) Andrea Sieber
Numbering as alphabets and have sub-points with a number
A.1 Presentation of the financial statements and annual report for the 2010 financial year with the report A.2 Supervisory Board, the group financial statements, the group annual report A.3 the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code B. Ratification of the acts of the Board of MDs C.1 Ratification of the acts of the Supervisory Board C.2. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt C.3. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi (3) Andrea Sieber
output:
A.1 Presentation of the financial statements and annual report for the 2010 financial year with the report
A.2 Supervisory Board, the group financial statements, the group annual report
A.3 the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code
B. Ratification of the acts of the Board of MDs
C.1 Ratification of the acts of the Supervisory Board
C.2. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt
C.3. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi (3) Andrea Sieber
Numbering as alphabets [Roman numbers]
I. Presentation of the financial statements and annual report for the 2010 financial year with the report II. Supervisory Board, the group financial statements, the group annual report III. the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code IV. Ratification of the acts of the Board of MDs V. Ratification of the acts of the Supervisory Board VI. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt VII. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi VIII. Election of Andrea Sieber as a director
output:
I. Presentation of the financial statements and annual report for the 2010 financial year with the report
II. Supervisory Board, the group financial statements, the group annual report
III. the report pursuant to Sections 289(4) and 315(4) of the German Commercial Code
IV. Ratification of the acts of the Board of MDs
V. Ratification of the acts of the Supervisory Board
VI. Appointment of auditors for the 2011 financial year: PricewaterhouseCoopers AG, Frankfurt
VII. Elections to the Supervisory. Board (1) Peter Maria Wagner (2) Michael Hirschi
VIII. Election of Andrea Sieber as a director
Please help in developing macro for normal numerical, (1,2,3,4..10,103,178 so on) Roman numbering (I, II, III, IX, X, XII....XXV So on), alphabets (A, B, C....X,Y,Z) and for spliting
I guess your problem is the following. You have an array of delimiters. And you would like to return new paragraph and the same delimiter.
So the problem splits into parts.
Create the delimiters. There are three types:
Arabic numerals. Here is the array: ("1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12.", "13.", "14.", "15.", "16.", "17.", "18.", "19.", "20."). If you need more numbers: http://textmechanic.com/generate-list-numbers/.
Latin letters. Here is the array: ("A.", "B.", "C.", "D.", "E.", "F.", "G.", "H.", "I.", "J.", "K.", "L.", "M.", "N.", "O.", "P.", "Q.", "R.", "S.", "T.", "U.", "V.", "W.", "X.", "Y.", "Z.").
Roman numerals. Here is the array: ("I.", "II.", "III.", "IV.", "V.", "VI.", "VII.", "VIII.", "IX.", "X.", "XI.", "XII.", "XIII.", "XIV.", "XV.", "XVI.", "XVII.", "XVIII.", "XIX.", "XX."). If you need more numbers, take this http://www.rapidtables.com/math/symbols/roman_numerals.htm#list, copy-paste here: http://textmechanic.com/delimited-column-extractor/ and use as delimiter, then add needed prefix and suffix http://textmechanic.com/add-prefixsuffix-into-line/.
Replace delimiter for paragraph and delimiter. Find delimiter and replace for ^pdelimiter. You need a loop.
Here is the sample code with all Latin letters:
Option Explicit
Sub replaceArrayForArray()
'
'to create array use prefix\suffix and replacing tool http://textmechanic.com/
'
'
findArray = Array("A.", "B.", "C.", "D.", "E.", "F.", "G.", "H.", "I.", "J.", "K.", "L.", "M.", "N.", "O.", "P.", "Q.", "R.", "S.", "T.", "U.", "V.", "W.", "X.", "Y.", "Z.")
replArray = Array("A.", "^pB.", "^pC.", "^pD.", "^pE.", "^pF.", "^pG.", "^pH.", "^pI.", "^pJ.", "^pK.", "^pL.", "^pM.", "^pN.", "^pO.", "^pP.", "^pQ.", "^pR.", "^pS.", "^pT.", "^pU.", "^pV.", "^pW.", "^pX.", "^pY.", "^pZ.")
For i = 0 To UBound(findArray)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = findArray(i)
.Replacement.Text = replArray(i)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Next i
End Sub
Adapt your code for Arabic numerals, and Roman numerals.

vba loop through all the pivot fields of a pivot table and return specified values

I have a dataset whose entries has 5 different attributes and one value. For example, I have a height of 5000 people. For each person I have his hair color, eye color, his nationality, the city he were born and the name of his mother (the 5 dimensions).
No/Eye Color/Hair Color/Nationality/Hometown/Mother's Name/Height
Blue Blond Swiss Zürich Nicole 184
Blue Brown English York Ruby 164
Brown Brown French Paris Sophie 154
etc..
So there are 5 dimensions. The data is set dynamically, so the number of categories in each dimensions can vary. I sought to compute the average height of people depending on whether I want to include some dimensions or not (from 1 to 5). For example I wanted the retrieve:
The average height of French and Blue eyed people. Next day only the people born in London. And the week after, the Swiss, blue-eyed, red-haired, born in Geneva and whose mother is called Nicole.
So I create a pivot table with the Eye Color as Row labels, Hair Color as Column labels, the average height as the Data and the last 3 dimensions as Market Filters. This allowed me see all the possible and desired combinations of average height that my data implies.
Now my goal is:
I want to create a Macro that goes through all the possible combinations that my dimensions entails (i.e 2^5-1=31) and store in a vector all the combination of height average that are above a certain value, e.g. 190. And then It could print on a worksheet.
I was thinking on using some booleans arrays vector and For-Each-Next structure, but I must say that I fail to picture how to implement it.
Any ideas?
Thanks for the time and help!