Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b1a30cd
uploading my favorite quotes
CarlosRod178 Sep 23, 2020
650f199
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Sep 24, 2020
6a89b40
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 8, 2020
45b282b
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 13, 2020
8f4d580
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 15, 2020
3557864
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 20, 2020
d67e5ff
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 22, 2020
f41b16f
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 26, 2020
b62c22e
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Oct 29, 2020
184e62e
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 5, 2020
f8c933a
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 10, 2020
c10259a
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 12, 2020
3ac853a
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 17, 2020
7e2c4d8
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 18, 2020
4e04143
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 19, 2020
8b9aed5
Merge branch 'master' of https://github.com/compmem/compsy into my-br…
CarlosRod178 Nov 28, 2020
7ddd1d7
uploading Psyc4500 course material
CarlosRod178 Dec 23, 2020
788bd08
Trying to commit this change
CarlosRod178 Jul 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 8 additions & 0 deletions CS4500_CompMethods/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# COMPSY

This repository contains the content for the course *Computational
Methods in Psychology and Neuroscience*.

You can find the syllabus [here](syllabus/syllabus.pdf).

The [lessons](lessons) folder contains Jupyter notebooks for each lesson.
148 changes: 148 additions & 0 deletions CS4500_CompMethods/assignments/A01_Python_Functions.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Assignment 1: Python Functions\n",
"## Computational Methods in Psychology (and Neuroscience)\n",
"### Psychology 4500/7559 --- Fall 2020\n",
"By: Per B. Sederberg, PhD\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Objectives\n",
"\n",
"Upon completion of this assignment, the student will be able to:\n",
"\n",
"1. Create and run a Python script\n",
"\n",
"2. Demonstrate the use of basic math and comparison operators\n",
"\n",
"3. Use conditional statements in Python\n",
"\n",
"4. Use the \"for\" statement to create loops\n",
"\n",
"5. Create custom functions, using parameters to make them generalizable\n",
"\n",
"6. Document code with in-code comments and docstrings\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Assignment\n",
"\n",
"- Read Think Python chapters 3, 5, and 6 (Functions, Conditionals and Recursion, and Fruitful Functions). Be sure to open a new Jupyter Notebook and type in \n",
" the examples as you read through the text. You can also try the Exercises\n",
" at the end of each chapter.\n",
"\n",
"- After you have read the chapters, write code in *this notebook* (***after making a copy and renaming it to have your userid in the title --- e.g., A01_Python_Functions_mst3k***) that performs the \n",
" following tasks:\n",
"\n",
" 1. Get two numbers from the user \n",
" 2. Compare the numbers\n",
" 3. If the first number is smaller than the second, calculate the mean\n",
" 4. If the first number is larger than the second, calculate the difference\n",
" 5. If the two numbers are the same, calculate the factorial using a custom function\n",
" 6. Display the results (indicating what operation you did)\n",
"\n",
"- Test your code and debug as necessary.\n",
"\n",
"- ***When you are done, save this notebook as HTML (`File -> Download as -> HTML`) and upload it to the matching assignment on UVACollab.***\n",
"\n",
"## HINTS\n",
"\n",
"- Be sure to comment your code\n",
"- Make use of the `input` function to get numbers (see examples from class)\n",
"- Use the template below to calculate the factorial using a non-recursive\n",
" function\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Name: (your name here)\n",
"# User ID: (your userid here)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ***finish this function replacing the `pass` with your code***\n",
"def factorial(n):\n",
" \"\"\"\n",
" Add your docstring here\n",
" \"\"\"\n",
" # Check the input\n",
" pass\n",
"\n",
" # make sure the input is an integer greater than or equal to 1\n",
" if type(n) is not int:\n",
" # Let the user know you need an integer\n",
" pass\n",
" \n",
" # Initialize a variable to 1\n",
" pass\n",
"\n",
" # Successively multiply the variable by the integers 2 up to n\n",
" for blah in range(blahblah):\n",
" # do something here\n",
" pass\n",
" \n",
" # return the result\n",
" return result\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ***your code here for reading in the numbers and operating correctly***\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Challenge problem (not required, but fun!)\n",
"\n",
"- Re-write the factorial function using a recursive algorithm.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
165 changes: 165 additions & 0 deletions CS4500_CompMethods/assignments/A01_Python_Functions_chr4qt.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Assignment 1: Python Functions\n",
"## Computational Methods in Psychology (and Neuroscience)\n",
"### Psychology 4500/7559 --- Fall 2020\n",
"By: Per B. Sederberg, PhD\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Objectives\n",
"\n",
"Upon completion of this assignment, the student will be able to:\n",
"\n",
"1. Create and run a Python script\n",
"\n",
"2. Demonstrate the use of basic math and comparison operators\n",
"\n",
"3. Use conditional statements in Python\n",
"\n",
"4. Use the \"for\" statement to create loops\n",
"\n",
"5. Create custom functions, using parameters to make them generalizable\n",
"\n",
"6. Document code with in-code comments and docstrings\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Assignment\n",
"\n",
"- Read Think Python chapters 3, 5, and 6 (Functions, Conditionals and Recursion, and Fruitful Functions). Be sure to open a new Jupyter Notebook and type in \n",
" the examples as you read through the text. You can also try the Exercises\n",
" at the end of each chapter.\n",
"\n",
"- After you have read the chapters, write code in *this notebook* (***after making a copy and renaming it to have your userid in the title --- e.g., A01_Python_Functions_mst3k***) that performs the \n",
" following tasks:\n",
"\n",
" 1. Get two numbers from the user \n",
" 2. Compare the numbers\n",
" 3. If the first number is smaller than the second, calculate the mean\n",
" 4. If the first number is larger than the second, calculate the difference\n",
" 5. If the two numbers are the same, calculate the factorial using a custom function\n",
" 6. Display the results (indicating what operation you did)\n",
"\n",
"- Test your code and debug as necessary.\n",
"\n",
"- ***When you are done, save this notebook as HTML (`File -> Download as -> HTML`) and upload it to the matching assignment on UVACollab.***\n",
"\n",
"## HINTS\n",
"\n",
"- Be sure to comment your code\n",
"- Make use of the `input` function to get numbers (see examples from class)\n",
"- Use the template below to calculate the factorial using a non-recursive\n",
" function\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Name: Carlos Rodriguez\n",
"# User ID: chr4qt"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"def factorial(n):\n",
" \"\"\"\n",
" Takes whole number value 'n' and calculates the factorial\n",
" \"\"\"\n",
" result = 1 # Sets the base for the factorials to be multiplied by\n",
" for i in range(n+1): # Multiplies each of the numbers to result for factorial (+1 since noninclusive)\n",
" if i == 0:\n",
" result *= 1\n",
" else:\n",
" result *= i\n",
" return result # Returns factorial"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Provide inital numbers and add them to a list\n",
"numbers = []\n",
"num1 = input('Choose the first number: ')\n",
"numbers.append(num1)\n",
"num2 = input('Choose the second number: ')\n",
"numbers.append(num2)\n",
"\n",
"\n",
"# Examines input in list to determine if is valid digit. If so, converts to int. If not, asks for another number.\n",
"for each in numbers:\n",
" while type(each) is not int: \n",
" if each.isdigit():\n",
" swap = numbers.index(each)\n",
" each = int(each)\n",
" numbers[swap] = each\n",
" else:\n",
" swap = numbers.index(each)\n",
" each = input('You have entered a number that is not an integer, please try again: ')\n",
" numbers[swap] = each\n",
"\n",
"\n",
"# Applies proper operation depending on input. \n",
"# 1st less than 2nd gives mean. 1st greater than 2nd gives difference. 1st equals 2nd gives factorial using function above. \n",
"if numbers[0] < numbers[1]:\n",
" mean = (numbers[0] + numbers[1]) / 2\n",
" print(mean)\n",
"elif numbers[0] > numbers[1]:\n",
" dif = (numbers[0] - numbers[1])\n",
" print(dif)\n",
"elif numbers[0] == numbers[1]:\n",
" n = numbers[0]\n",
" print(factorial(n))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Challenge problem (not required, but fun!)\n",
"\n",
"- Re-write the factorial function using a recursive algorithm.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading