what character is used for comments?
#-hashtag
What is a program made of?
a collection of program statements
How do you use the print() function to display the message "Hello, World!"?
print("Hello, World!")
Write a code snippet that prints the following output:
I have 3 apples.
You have 5 apples.
One example:
print("I have 3 apples.\nYou have 5 apples.")
What are the four Built-in types that we focused on in the lecture?
Integers, Floating-point (float), strings, boolean
What is the role of the '\n' character in a string?
The end of a line.
What does dynamic typing mean in python?
Refers to the ability of a variable to dynamically change its data type
What do we call the act of combining strings using the + operator?
Concatenation
Provide 3 examples of dynamic typing.
x=1
x=3.0
x='hello'
give an example of integer and a float using the same number.
1, 1.0
What is the file extension used for Python scripts?
.py
Explain why the statement 10 = y is an error in Python.
In Python, the equal sign (=) is used for assignment, not for equality testing. The correct syntax is y = 10.
What is casting, and why is it used in Python?
Casting is the process of converting one data type to another. It is used to ensure that the data type of a variable is appropriate for the operation being performed.
Create a Python code snippet that means the following (3 is not equal to 5) print the result.
print(3 != 5) would print True
Explain why the type() function is used when dealing with user input.
The type() function is used to determine the data type of user input because, by default, the input function returns a string.
what does = and == mean in python?
= is an assignment to the variable
== means equal to
Why is program input important, and what are the various forms it can take?
Program input is crucial for obtaining data from the user, and it can come in various forms such as tactile, audio, visual, or text.
What language-agnostic syntax does the AP Exam use for testing programming questions?
The AP Exam uses either "text" format or "block" format for language-agnostic syntax.
Use the input() function to create a program that accepts a user's name and prints a greeting.
(Use the + symbol, also add an ! point at the end of the greeting)
name=(input("what is your name?"))
print('hello',name+'!')
What are the 6 basic built-in types?
int, float, complex, boolean, string, nonetype
x=5
y=3 +x
x= y+2
z=x*y
print (z)
80
How is the assignment operator represented on the AP Exam, and what function replaces print()?
The assignment operator uses an arrow notation, and the display() function replaces print() on the AP Exam.
Provide an example of all 6 built-in types. (use the format x= )
x=1 x='abc'
x=1.0 x= None
x=1+2i x= true