Limited time offer 20% OFF StudySoup Subscription details

UH - COSC 1306 - COSC Test 2 - Study Guide

Created by: Yashwanth Reddy Gurijala Elite Notetaker

UH - COSC 1306 - COSC Test 2 - Study Guide

School: University of Houston
Department: Computer Science and Engineering
Course: Computer Science and Program
Professor: Serkan Dursun
Term: Spring 2017
Tags: #COSC1306 and Python
Name: COSC Test 2
Description: These notes cover the upcoming quiz
Uploaded: 11/05/2017
0 5 3 27 Reviews
This preview shows pages 1 - 2 of a 4 page document. to view the rest of the content
background image Computer Science and Programming Quiz #2 What are the main things to know about:
1) Selection and Loops
2) Functions
3) Lists
4) Files and dictionaries 
5) Tuples
6) Turtles
Different kinds of loops
1) for loop 
- Use this when you know how many times your loop  needs to run  - Use for function to use this loop 2) While loop - Use this when you don’t know how many times your  loops needs to run - Use while to use this loop 3) Selection loop - Selection loop means use if and else statement in any  of the for or while loop - Inside for or while use if, elif or else to use this kind of  loop Functions 
1) A function is something you can create for one certain set 
of instructions rather than writing the same code over and
over again
2) We use def function call to define a function and give it a  name and a parameter 3) You can call your function back again by using its name  Lists 
1) A list is storage of certain values 
2) List is stored in []
3) You can add, delete or replace a value in a list 
4) Every value in list starts in place from 0 not 1
5) Use append to add values to list
background image Files and Dictionaries 
1) You can call a file through code 
2) The place where this information is stored is called a 
dictionary  Tuples
1) Tuples is a form of list which cannot be changed but 
values can be appended to it  2) It is stored in {} brackets  Turtle
1) A turtle can be used to draw anything 
2) You need to call a turtle in the beginning of the program to
use this function  Questions  1) Write a program that can list and add consecutive  square numbers depending on the input  2) Write a program that can add 5 consecutive numbers 
3) Write a function number(a) in which it takes the user 
number and determines if it is an odd or even number 4) Write a program using turtles to draw a square with the  function square() in it Answers ( one of the possibilities not the only answer) 1) >>> number = 1 >>> All_square_numbers = []
>>> Adding_Square_Numbers = 0
>>>a = int(input("How many square numbers do you 
want to add \n"
))
>>> while number <= a:
    
Square_numbers = number ** 2      All_square_numbers.append(Square_numbers)      number += 1

This is the end of the preview. Please to view the rest of the content
Join more than 18,000+ college students at University of Houston who use StudySoup to get ahead
4 Pages 191 Views 152 Unlocks
  • Better Grades Guarantee
  • 24/7 Homework help
  • Notes, Study Guides, Flashcards + More!
Join more than 18,000+ college students at University of Houston who use StudySoup to get ahead
School: University of Houston
Department: Computer Science and Engineering
Course: Computer Science and Program
Professor: Serkan Dursun
Term: Spring 2017
Tags: #COSC1306 and Python
Name: COSC Test 2
Description: These notes cover the upcoming quiz
Uploaded: 11/05/2017
4 Pages 191 Views 152 Unlocks
  • Better Grades Guarantee
  • 24/7 Homework help
  • Notes, Study Guides, Flashcards + More!
Join StudySoup for FREE
Get Full Access to UH - COSC 1306 - Study Guide - Midterm
Join with Email
Already have an account? Login here
×
Log in to StudySoup
Get Full Access to UH - COSC 1306 - Study Guide - Midterm

Forgot password? Reset password here

Reset your password

I don't want to reset my password

Need help? Contact support

Need an Account? Is not associated with an account
Sign up
We're here to help

Having trouble accessing your account? Let us help you, contact support at +1(510) 944-1054 or support@studysoup.com

Got it, thanks!
Password Reset Request Sent An email has been sent to the email address associated to your account. Follow the link in the email to reset your password. If you're having trouble finding our email please check your spam folder
Got it, thanks!
Already have an Account? Is already in use
Log in
Incorrect Password The password used to log in with this account is incorrect
Try Again

Forgot password? Reset it here