CISP 41 Summer2023 Chapter2 Using Data

CISP 41 Summer2023 Chapter2 Using Data

Introduction and Module Overview

The instructor introduces the module and provides an overview of the different parts of the module, including assignments that students need to complete.

Downloading Course Materials

  • Students are instructed to download course materials, including a PDF, key terms, examples, PowerPoint presentation, notes, and homework.
  • Homework is due on June 28th.
  • Programming classwork will be done in groups for extra points.

Downloading Chapter 2 Materials

The instructor explains how to download chapter 2 materials and extract them into a folder.

Downloading Chapter 2 Materials

  • Students are instructed to download chapter 2 notes and key terms, PowerPoint presentation, examples and exercises.
  • Students should extract the examples and exercises into a subfolder named "Chapter 2 Fun."

Opening Visual Studio

The instructor explains how to open Visual Studio and access project files.

Opening Project Files in Visual Studio

  • Students should save file open project and solution.
  • They should navigate to their desktop and double-click on the "Chapter Two" folder.
  • They should then click on "Chapter Two Fun Solution" to open it in Visual Studio.

Exploring Code Examples

The instructor introduces code examples that students will work with in this module.

Navigating Solution Explorer

  • Solution Explorer contains project files with extension CS for C sharp.
  • Right-clicking on Chapter Two Fun allows students to add a new class.
  • A new example is introduced by right-clicking on the solution explorer.

Adding New Class Files

The instructor demonstrates how to add new class files in Visual Studio.

Adding New Class Files

  • Students should right-click on Chapter Two Fun and select "Add" then "Class."
  • They can then name the class file and click "Add."

Copying Files to Desktop

The instructor demonstrates how to copy files from Visual Studio to the desktop.

Copying Files to Desktop

  • Students should right-click on the Chapter Two Fun folder in Solution Explorer and select "Copy."
  • They should then navigate to their desktop and right-click, selecting "Paste."

Opening Visual Studio 2017

The instructor explains how to open Visual Studio 2017.

Opening Visual Studio 2017

  • Students should have installed Visual Studio 2017 Community Edition.
  • They can access it by saving file open project and solution.
  • They should navigate to their desktop, double-click on the "Chapter Two" folder, and click on "Chapter Two Fun Solution" to open it in Visual Studio.

Introduction to Variables and Data Types

In this section, the instructor introduces variables and data types in C#. The section covers what a variable is, how to declare a variable, and the different data types available in C#.

Declaring a Variable

  • A variable is a named memory location that stores a value.
  • When declaring a variable, you need to specify its data type.
  • Different data types have different memory allocations and ranges of values.

Data Types in C#

  • C# has several data types including int, byte, short, long, double, float, decimal, char, boolean and string.
  • Integers are whole numbers while double and float are numbers with decimal places.
  • Decimal has higher precision than other numeric data types.
  • Char represents single characters while string represents series of characters.

Constants vs Variables

  • Constants cannot be changed while variables can be assigned new values.
  • A constant is taken literally as chosen while variables are named memory locations that store values.

Conclusion

In this section we learned about what variables are and how they work in C#. We also covered the different data types available in C#, their characteristics and how to declare them.

Numeric Variables and Type Conversion

In this section, the speaker explains how to declare and assign values to numeric variables in C#. They also discuss arithmetic operations with variables of different data types and the need for type conversion.

Declaring Numeric Variables

  • To declare a numeric variable in C#, use the syntax "int X = 5", where X is the name of the variable and 5 is its initial value.
  • If you don't want to assign an initial value, you can simply declare it using "int X;".

Arithmetic Operations with Numeric Variables

  • To perform arithmetic operations with numeric variables, use operators such as +, -, *, /, %.
  • When performing arithmetic operations with operands of similar data types, the result will be of the same data type. No conversion is needed.
  • When performing arithmetic operations with operands of different data types, C# implicitly converts them to a unifying data type for the result. This is called type conversion.

Type Conversion

  • Type conversion is needed when performing arithmetic operations with operands of dissimilar data types.
  • The four commonly used data types in C# are double, float, int, and char. They have different precedence levels when it comes to type conversion.
  • Explicit cast can be used to convert a higher precedence data type (e.g., double) to a lower precedence one (e.g., int). Use syntax like "int X = (int) Y;" to explicitly cast a double variable Y to an integer variable X.

Adding Console using Static

In this section, the speaker demonstrates how to add the console using static and explains what a directive is.

Declaring a Variable

  • Declare an integer variable named X and assign it a value of 5.
  • Use Console.WriteLine to display the value of X on the console.
  • Explain that declaring a variable involves assigning a value to it and that Console.WriteLine displays the value on the console.

Displaying Multiple Variables

  • Declare a double variable named Y and assign it a value of 6.5.
  • Use placeholders to display both X and Y variables on the console.

Opening Another Project

In this section, the speaker opens another project in Visual Studio.

Fixing Errors in Previous Project

  • No bullet points with timestamps available for this section.

Adding Class One as Starting Point

  • Set Class One as starting point for project.

Printing Variables Using Placeholders

In this section, the speaker demonstrates how to use placeholders to print multiple variables on the console.

Declaring Double Variable Y

  • Declare a double variable named Y and assign it a value of 6.5.

Using Placeholders

  • Use placeholders to display both X and Y variables on the console.

Printing and Manipulating Strings

In this section, the speaker demonstrates how to print and manipulate strings in Python.

Printing Strings

  • To print a string, use the print() function.
  • To concatenate two strings, use the + operator.
  • To format a string with variables, use curly braces `` as placeholders and provide the values using .format().

Manipulating Strings

  • To declare a string variable, enclose it in double quotes " ".
  • Use camel case for variable names with no spaces or numbers at the beginning.
  • To access individual characters in a string, use indexing starting from 0.
  • To convert a string to uppercase or lowercase, use .upper() or .lower(), respectively.

Introduction to Variables and Operations

In this section, the instructor introduces variables and operations in programming. The section covers how to change a string variable to uppercase or lowercase, explicit conversion of data types, arithmetic operators, shortcut arithmetic operators, increments, and post/pre-increments.

Changing String Variable Case

  • To change a string variable to uppercase: use the ToUpper() method on the first name variable.
  • To change a string variable to lowercase: use the ToLower() method on the first name variable.

Explicit Conversion of Data Types

  • When performing an operation with different data types (e.g., double and integer), explicit conversion is necessary.
  • To explicitly convert a double data type to an integer data type: use int before the operation.

Arithmetic Operators

  • Common mathematical operations include addition, multiplication, and division.
  • Shortcut arithmetic operators can be used for shorthand notation. For example: a += b is equivalent to a = a + b.

Increments

  • Incrementing adds one to a variable.
  • Post-increment (count++) increments after using the value of count in an expression.
  • Pre-increment (++count) increments before using the value of count in an expression.

Variables and Substrings

In this section, the instructor discusses variables in C# and how to declare them. They also cover incrementing variables using different methods and introduce the concept of substrings.

Declaring Variables

  • The instructor declares an integer variable called "count" with a value of 20.
  • It is recommended to declare all variables at the beginning of the code.

Incrementing Variables

  • The instructor demonstrates how to increment a variable by adding 1 to it using "count = count + 1".
  • Another way to increment a variable is by using "count++" or "++count".
  • The instructor shows that prefix incrementing can have unexpected results when assigning values to multiple variables.

Substrings

  • The instructor introduces substrings as a way to extract part of a string.
  • They demonstrate how to use the substring method in C# with an example string "we are having fun".

Introduction to C#

In this section, the speaker introduces C# and discusses how to replace strings, use string properties, and split strings.

Replacing Strings

  • To replace a string in C#, use the replace method.
  • To replace "C sharp" with "Python", use greetings.Replace("C sharp", "Python").

String Properties

  • The length property counts the number of characters in a string.
  • Use greetings.Length to count the number of characters in the greetings string.

Splitting Strings

  • Use the split method to split a string based on a specific character.
  • Use greetings.Split(' ') to split the greetings string by spaces.

Formatting Strings in C#

In this section, the speaker discusses how to format strings using placeholders and demonstrates how to assign values at declaration.

Formatting Strings

  • To format strings in C#, use curly brackets `` as placeholders.
  • Use 0,5 inside curly brackets to give index 0 five spaces.

Assigning Values at Declaration

  • You can declare and assign values at the same time in C#.
  • For example: double X = 69.875; int A = 5;

This transcript is incomplete and may not provide a full understanding of the video content.

Introduction to Formatting

In this section, the speaker introduces formatting in C# and discusses different types of format specifiers.

Format Specifiers

  • The speaker explains that "0.5" is a floating-point number.
  • The speaker mentions the format specifier and conversion operators for float, double, and decimal data types.

Arithmetic Operators

  • The speaker discusses the order of precedence for arithmetic operators in C#, starting with multiplication and division before addition and subtraction.
  • The speaker provides an example of using parentheses to change the order of operations.

String Functions

  • The speaker covers string functions such as ToLower() and ToUpper().
  • An example is given that demonstrates how to use multiple string functions in one line of code.

Troubleshooting Example Code

  • The speaker addresses an issue with a program not displaying correctly due to a missing console.read key statement.
  • A corrected version of the program is uploaded for students to download.

Overall, this section provides an introduction to formatting in C#, covering topics such as format specifiers, arithmetic operators, string functions, and troubleshooting common issues.

Break and Instructions for Teams

In this section, the speaker gives instructions to the audience on what they should do during the break.

Splitting into Teams

  • The speaker informs the audience that they will be split into teams after the break.
  • The speaker shows where the teams will be going after the break and instructs everyone to go to "cisp 41 All Of Us Together."

Instructions for After the Break

  • The speaker tells everyone that they have until 7:45 pm to complete their task.
  • The speaker shows a Zoom link that everyone needs to click on in order to join a meeting.
  • The meeting will last for one hour.

Joining the Meeting

  • The speaker instructs everyone on how to join the meeting by clicking on a link provided.
  • Everyone is asked if they were able to join and told that there is no need to download any program, just join it.