Initialize a new react-native application:
react-native init MyNativeApp
cd MyNativeApp/
# | |
# My awesome program! (basic version without integer input validation) | |
# | |
# ask the user how many cookies: | |
cookieCount = input("HOW MANY COOKIES DO YOU WANT TO MAKE? ") | |
# provide affirmative feedback to the user: |
import os | |
# | |
# PARSE STUDENT ANSWERS FROM FILE | |
# | |
# choose the right file (must be in the same directory as this script!) | |
filename = os.path.join(os.path.dirname(__file__), 'student_answers.csv') | |
print(filename) |
Jacob | |
Michael | |
Joshua | |
Matthew | |
Daniel | |
Christopher | |
Andrew | |
Ethan | |
Joseph | |
William |
phone_input = input("Please enter a ten-digit phone number using numbers and/or capital letters (using quotation marks, e.g. '555-GET-FOOD'): ") | |
print("YOU ENTERED: " + phone_input) | |
def translate_character_to_number(char): | |
clean_char = str(char).upper() | |
if clean_char in ["A","B","C"]: | |
return "2" | |
elif clean_char in ["D","E","F"]: | |
return "3" |
import os | |
def convert_file_to_list(file_name): | |
file_path = os.path.join(os.path.dirname(__file__), file_name) | |
# read the file contents into memory | |
infile = open(file_path, 'r') | |
my_list = infile.readlines() | |
infile.close() |
courses = { | |
'CS101': {'room_number': '3004', 'instructor': 'Haynes', 'meeting_time': '8:00 am'}, | |
'CS102': {'room_number': '4501', 'instructor': 'Alvarado', 'meeting_time': '9:00 am'}, | |
'CS103': {'room_number': '6755', 'instructor': 'Rich', 'meeting_time': '10:00 am'}, | |
'NT110': {'room_number': '1244', 'instructor': 'Burke', 'meeting_time': '11:00 am'}, | |
'CM241': {'room_number': '1411', 'instructor': 'Lee', 'meeting_time': '1:00 pm'}, | |
} | |
course_number = input("Please input a course number. It should be one of: 'CS101', 'CS102', 'CS103', 'NT110', 'CM241'.") |
from random import shuffle | |
state_capitals = { | |
"Alaska": "Juneau", | |
"Arizona": "Phoenix", | |
"Arkansas": "Little Rock", | |
"California": "Sacramento" | |
} # todo: get the rest from the internet |
import os | |
import pickle # reference: https://wiki.python.org/moin/UsingPickle | |
# | |
# Write a program that keeps names and email addresses in a dictionary as key-value pairs. | |
# Each time the program starts, it should retrieve the dictionary from the file and unpickle it. | |
# | |
ADDRESS_BOOK_FILE_NAME = os.path.join(os.path.dirname(__file__), "address_book.p") |
# resources: | |
# https://docs.python.org/3/tutorial/classes.html | |
# https://www.tutorialspoint.com/python/python_classes_objects.htm | |
# https://learnpythonthehardway.org/book/ex40.html | |
class Pet: | |
# expects to be instantiated using a dictionary like ... | |
# pet = Pet({'name':'Kirby', 'type':'Dog', 'age':'really old'}) | |
def __init__(self, options): |