Download presentation
Presentation is loading. Please wait.
1
CSE 1321 - Module 1 A Programming Primer
4/11/2019 CSE 1321 Module 1
2
Ps Skeletons BEGIN MAIN END MAIN
Note: every time you BEGIN something, you must END it! Write them as pairs! 4/11/2019 CSE 1321 Module 1
3
Skeletons def main(): pass if __name__ == '__main__': main()
Note: technically, you don’t have to do this. It’s complicated… 4/11/2019 CSE 1321 Module 1
4
Ps Printing BEGIN MAIN PRINT “Hello, World!”
PRINT “Bob” + “ was” + “ here” END MAIN Ps 4/11/2019 CSE 1321 Module 1
5
Printing def main(): print ("Hello, World!")
print ("Bob"+" was"+" here") if __name__ == '__main__': main() 4/11/2019 CSE 1321 Module 1
6
Declaring/Assigning Variables
BEGIN MAIN CREATE userName CREATE studentGPA userName ← “Bob” studentGPA ← 1.2 END MAIN userName “Bob” studentGPA 1.2 Ps 4/11/2019 CSE 1321 Module 1
7
Declaring/Assigning Variables
def main(): userName = 'Bob' studentGPA = 1.2 if __name__ == '__main__': main() 4/11/2019 CSE 1321 Module 1
8
Reading Text from the User
BEGIN MAIN CREATE userInput PRINT “Please enter your name” READ userInput PRINT “Hello, ” + userInput END MAIN Ps 4/11/2019 CSE 1321 Module 1
9
Reading Text from the User
def main(): userInput = input("Please enter your name: ") print ("Hello, ” + userInput) if __name__ == '__main__': main() 4/11/2019 CSE 1321 Module 1
10
Reading Numbers from the User
BEGIN MAIN CREATE userInput PRINT “Please enter your age: ” READ userInput PRINT “You are ” + userInput + “ years old.” END MAIN Ps 4/11/2019 CSE 1321 Module 1
11
Reading Numbers from the User
def main(): age = int(input("Please enter your age: ")) print ("You are ",age," years old.") if __name__ == '__main__': main() 4/11/2019 CSE 1321 Module 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.